CentOS7.2 install Mysql5.7.13

1. MySQL 5.7 Main features:

(1) Native support for Systemd

(2) Better performance: better optimization for multi-core CPUs, solid state drives, and locks

(3) Better InnoDB storage engine

(4) More robust replication function: Replication brings a solution that does not lose data at all. Traditional financial customers can also choose to use MySQL database.

Note: mysql-5.6.3 already supports multi-threaded master-slave replication

(5) New sys library: in the future, this will be the most frequently accessed library by DBA

2. Install mysql5.7.13 (compile and install mysql5.7)

1、 System environment: centos7.2 x86_64

Because centos7.2 installs mariadb-libs by default, uninstall it first

Check if mariadb is installed

rpm -qa | grep mariadb

Uninstall mariadb

rpm -e --nodeps mariadb-libs

2、 Install dependent packages (Note: the role of dependent packages)

cmake: Since the conventional configure compilation method has been abandoned since MySQL 5.5, a CMake compiler is required to set the compilation parameters of mysql. Such as: installation directory, data storage directory, character encoding, sorting rules, etc.
Boost #Boost library is required starting from MySQL 5.7.5. C++ Boost library is used in mysql source code. Boost 1.59.0 or above must be installed
**GCC ** is a C language compilation tool under Linux, mysql source code compilation is completely written in C and C++, and GCC must be installed
bison: C/C++ syntax analyzer under Linux
ncurses: character terminal processing library

Download cmake-3.5.tar.gz http://www.cmake.org/download/
Download ncurses-5.9.tar.gzftp://ftp.gnu.org/gnu/ncurses/
Download bison-3.0.4.tar.gz http://ftp.gnu.org/gnu/bison/
Download mysql-5.7.13.tar.gz
wgethttp://cdn.mysql.com/Downloads/MySQL-5.7/mysql-5.7.13.tar.gz
Download Boost_1_59_0.tar.gz
wget http://nchc.dl.sourceforge.net/project/boost/boost/1.59.0/boost_1_59_0.tar.gz

(1) Install CMAKE and necessary software

Install cmake

cmake --version-view cmake version

Install ncurses

Install bison

Install bootst

tar zxf boost_1_59_0.tar.gz

mv boost_1_59_0 /usr/local/boost

2 ) Create mysql users and user groups and directories

groupadd -r mysql && useradd -r -g mysql -s /bin/false -M mysql

—— New msyql group and msyql users are prohibited from logging into the shell

mkdir /usr/local/mysql-create a directory

mkdir /usr/local/mysql/data-database directory

3、 Compile and install mysql

Unzip the mysql source code package:

Execute the cmake command to configure before compilation:

Start to compile, compile and install:

make && make install

**Configuration explanation: **

  • DCMAKE_INSTALL_PREFIX=/usr/local/mysql [root directory of MySQL installation]
  • DMYSQL_DATADIR=/usr/local/mysql/data [MySQL database file storage directory]
  • DSYSCONFDIR=/etc [Directory where MySQL configuration file is located]
  • DWITH_MYISAM_STORAGE_ENGINE=1 [Add MYISAM engine support]
  • DWITH_INNOBASE_STORAGE_ENGINE=1 [Add InnoDB engine support]
  • DWITH_ARCHIVE_STORAGE_ENGINE=1 [Add ARCHIVE engine support]
  • DMYSQL_UNIX_ADDR=/usr/local/mysql/mysql.sock [Specify the location of mysql.sock]
  • DWITH_PARTITION_STORAGE_ENGINE=1 [installation support database partition]
  • DEXTRA_CHARSETS=all [make MySQL support all extended characters]
  • DDEFAULT_CHARSET=utf8 [Set the default character set of MySQL to
    utf8]-DDEFAULT_COLLATION=utf8_general_ci [Set the collation rules of the default character set]
  • DWITH-SYSTEMD=1 [You can use systemd to control the mysql service]
  • DWITH_BOOST=/usr/local/boost [point to the directory where the boost library is located]
    More parameters execute # cmake. -LH

In order to speed up the compilation speed, you can compile and install as follows

make -j $(grep processor /proc/cpuinfo | wc –l)

4、 Optimize the execution path of Mysql

5、 Set permissions and initialize the MySQL system authorization table

cd /usr/local/mysql

chown -R mysql:mysql. ——Change the owner, belong to the group, pay attention to mysql.

bin/mysqld --initialize --user=mysql --basedir=/usr/local/mysql

Note 1: Add the --user=mysql parameter when initializing the operation as root to generate a random password (note that it is used when saving the login)

Note 2: Before MySQL 5.7.6, execute this script to initialize the system database

/usr/local/mysql/bin/mysql_install_db--user=mysql --basedir=/usr/local/mysql

5.7.6 The initial system database script of the later version (this article uses this method to initialize)

/usr/local/mysql/bin/mysqld --initialize-insecure --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data

Note: If you use the -initialize parameter to initialize the system database, a temporary password for the root user will be generated, as shown in the figure above.

6、 Create configuration file

cd /usr/local/mysql/support-files ——Enter MySQL installation directory support file directory

cp my-default.cnf /etc/my.cnf —— copy the template as a new configuration file (if there is no my-defalut.cnf template, you can create /etc/my.cnf manually)

Modify the configuration options in the file, as shown in the figure below, add the following configuration items

vi /etc/my.cnf

7、 Configure mysql to start automatically

The service failed to start, check the error log file

In mysqld.service, the default pid file is assigned to the /var/run/mysqld/ directory, and the directory is not created in advance, so you must manually create the directory and assign permissions to the mysql user.

Or modify /usr/lib/systemd/system/mysqld.service, the modification content is as follows:

systemctl daemon-reload

Start the mysql service again

View port number

Service started successfully

Access MySQL database

mysql -u root -h127.0.0.1-p ——Connect to mysql, enter the random password generated during initialization

Set the password of the database administrator user root

Three, binary installation mysql5.7

As mentioned above, mysql compile and install, binary installation is similar to compile and install, but you don't need to compile by yourself, here is a brief step.

1、 First check whether the MySQL package has been installed in the virtual machine, and uninstall it if there is one

2、 Unpack and move to /usr/local/mysql, and create a data directory under the mysql directory (the binary package can be downloaded from the mysql official website: https://www.mysql.com/)

3、 Create mysql user and group

4、 Change the owner and group of the mysql directory to mysql and view

5、 Optimize the execution path of mysql

Source /etc/profile

6、 Write the mysql configuration file /etc/my.cnf

7、 Add mysqld to system services

8、 Initialize the database

9、 Check the mysqld.err file in the data directory, which shows the initial password of root

10、 Start the MySQL service and view the port

11、 Display an error message when logging in, modify the configuration file /etc/my.cnf, and restart the service.

12、 Log in to the mysql database

Four, YUM install mysql5.7

1、 Check whether the mysql service is installed in the system

2、 Download the yum source of mysql5.7.

wget http://repo.mysql.com/mysql57-community-release-el7-8.noarch.rpm

3、 Install mysql57-community-release-el7-8.noarch.rpm:

rpm -ivhmysql57-community-release-el7-8.noarch.rpm

After installation, you get the following two packages:

mysql-community.repo
mysql-community-source.repo

4、 Install MySQL, if prompted, go all the way to the end

yum install mysql-server

After the installation is complete, run mysql, and a random password will be automatically generated in the /var/log/mysqld.log file. We need to obtain this random password first to log in to the MySQL server:

service mysqld start

grep "password" /var/log/mysqld.log

Will return the following content, the last string is the password, copy it:

Atemporary password is generated for root@localhost: hilX0U!9i3_6

5、 Log in to the MySQL server and update the password of user root:

Note: Since MySQL 5.7 uses the password strength verification plug-in validate_password, we need to set a password with a certain strength;

mysql -uroot -p'hilX0U!9i3_6'

Then change the password

SET PASSWORD = PASSWORD('your new password');

ALTER USER'root'@'localhost' PASSWORD EXPIRE NEVER;flushprivileges;

The above is the specific steps of centOS7 to install mysql5.7.

Recommended Posts

CentOS7.2 install Mysql5.7.13
CentOS7 install MySQL
CentOS install mysql
CentOS7 install mysql
CentOS 7 install MySQL 5.6
CentOS8 install MySQL8.0
CentOS7 install mysql8
CentOS7 install MySQL8
centos 7.5 install mysql5.7.17
CentOS6.5 offline install MySQL5.6.26
Install MySQL5.7 in centos7
Install mysql5.7 under CentOS7
CentOS 7.2 Yum install MySQL 5.6
Centos7 install Mysql8 tutorial
Centos manually install mysql8
Install mysql under Centos 7
Centos7 install Mysql database
Install mysql5.1 under CentOS6.5
1.5 Install Centos7
Install mysql online on centos
centos install mysql through yum
Install MySQL 8.0.16 on Linux Centos
Install MySQL under Linux (CentOS 7)
Centos6 install mysql 5.7.x series
CentOS8 install MySQL8 (pro test)
Centos6 install Python2.7.13
How to install MySQL on CentOS 8
CentOS7 yum install and start mysql
Centos7.3 install nginx
CentOS Yum compile and install MySQL 5.6
CentOS install Redmine
Centos7 install Python 3.6.
Centos7 install protobuf
CentOS 7 install Docker
CentOS 7 install Nginx, PHP, MySQL packages
CentOS7 install GlusterFS
CentOS 7.4 install Zabbix 3.4
CentOS7 install Docker
Centos6.5 install Tomcat
CentOS install Python 3.6
Vmware install CentOS6
centos7 install docker-ce 18.01.0
CentOS 7.2 install MariaDB
CentOS 7 install Hadoop 3.0.0
Install MySql with Docker in CentOS7
Centos7 install Python2.7
Centos 7.6 install seleniu
CentOS 7.3 install Zabbix3
Centos7 install LAMP+PHPmyadmin
Install MySQL on Linux CentOS7 (Windows)
CentOS install openjdk 1.8
CENTOS6.5 install CDH5.12.1 (1)
CentOS install PHP
CentOS7 yum install and start mysql
CentOS6 install mist.io
Centos7 install Docker
Centos7 and centos8 install mysql5.6 5.7 8.0 so simple
Centos yum install mysql5.6 or above
centOs install rabbitMQ
Centos7 install Nginx
CentOS6.5 install CDH5.13