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
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 libraryDownload 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
—— New msyql group and msyql users are prohibited from logging into the shell
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:
**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. -LHIn 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
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
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
Modify the configuration options in the file, as shown in the figure below, add the following configuration items
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:
Start the mysql service again
View port number
Service started successfully
Access MySQL database
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