1.MySQL compiled installation requires the use of the CMake and boost C + + libraries, so you need to install the CMake and compilers ahead of time before installing.
2. Download the MySQL source code and select Download generic linux (architecture independent), compressed tar Version archive includes boost headers, which contains Boost library information and does not need to be downloaded separately
[Email protected] local]# wget http://dev.mysql.com/get/Downloads/MySQL-5.7/mysql-boost-5.7.15.tar.gz
3. Add MySQL User
[[email protected] local]# groupadd mysql[[email protected] local]# useradd-r-g mysql-s/bin/nologin MySQL br>
4. Extracting MySQL installation media
[[email protected] local]# tar-zxvf mysql-boost-5.7.15.tar.gz [[email protected] local]# CD mysql-5.7.15/
5. Compiling and installing MySQL
[[email protected] local]# mkdir-p/mysql/data[[email protected] local]# cmake-dcmake_install_prefix=< Span style= "COLOR: #ff0000" >/usr/local/mysql -dmysql_datadir=/mysql/data -dwith_boost=/usr/local/mysql-5.7.15/boost/boost_1_59_0 [[email Protected] mysql-5.7.15]# make[[email protected] mysql-5.7.15]# make install
Clear compilation error message
[[email protected] mysql-5.7.15]# make clean[[email protected] mysql-5.7.15]# rm CMakeCache.txt
6. Initializing MySQL Database
[Email protected] ~]# cd/usr/local/mysql/[[email protected] mysql]# chown-r mysql:mysql./[[email protected] mysql]# bi n/mysqld--initialize--user=mysql--basedir=/usr/local/mysql--datadir=/mysql/data2016-10-06t05:11:36.422748z 0 [Warning] TIMESTAMP with Implicit DEFAULT value is deprecated. --explicit_defaults_for_timestamp server option (see documentation for more details). 2016-10-06t05 : 11:36.832157z 0 [Warning] innodb:new log files created, lsn=457902016-10-06t05:11:36.900930z 0 [Warning] Innodb:creatin G FOREIGN KEY constraint system tables.2016-10-06t05:11:36.961751z 0 [Warning] No existing UUID have been found, so we assu Me that's the first time that this server has been started. Generating a new uuid:5b4533be-8b83-11e6-927a-0800279bbbbf.2016-10-06t05:11:36.963090z 0 [Warning] Gtid table is not rea Dy to be used. Table ' mysql.gtid_executed ' cannot be opened.2016-10-06t05:11:36.964712z 1 [Note] A temporary password are generated for [E Mail protected]:; uiy2:zvrv) u[[email protected] mysql]# Bin/mysql_ssl_rsa_setup--datadir=/mysql/datagenerating a 2048 bit RSA private key......+++ ..... ..... ..... ..... ..... ..... ..... ....... ....... ......... ..... ..... ..... ..... ..... ..... ..... ....... .............. +++writing New private key to ' CA-KEY.PEM '-----generating a 2048 bit RSA private key...........................+++ ..... ..... ......................................................................................................................... .... +++writing new private key to ' SERVER-KEY.PEM '-----generating A, ... ..... ..... ..... .....???????????????????????????????????????????. 2048 bit RSA Private key.................+++ ......................................................................................................................... .. +++writing new private key to ' CLIENT-KEY.PEM '-----
mysql 5.7.6 Previous version, use the following command to initialize bin/mysql_install_db--user=mysql
7. Start the MySQL database (compile the installed MySQL, the/etc/my.cnf file will be created by default)
[[email protected] ~]# cd/mysql[[email protected] mysql]# mkdir log[[email protected] mysql]# mkdir run[[email Protec Ted] ~]# chown-r mysql:mysql/mysql[[email protected] mysql]# cat/etc/my.cnf [mysqld]//non-default parameters affect the start-stop database by service mode datadir=/mysql/datauser=mysql# Disabling symbolic-links is recommended to prevent assorted security Riskssymbolic-links=0[mysqld_safe][[email protected] mysql]# bin/mysqld_safe--user=mysql &[1] 27572[[email Protected] mysql]# 2016-10-06t05:21:00.684235z mysqld_safe Logging to '/mysql/log/mysqld.log '. 2016-10-06t05 : 21:00.709272z Mysqld_safe starting mysqld daemon with databases From/mysql/data
8. Log in to MySQL database
[[email protected] ~]# vi/root/.bash_profile path= $PATH: $HOME/bin:/usr/local/mysql/bin//Add MySQL path to environment variable [ email protected] ~]#/root/.bash_profile [[email protected] mysql]# mysql-u root-h localhost-penter Password: C7>;UIY2:ZVRV) uWelcome to the MySQL Monitor. Commands End With; or \g.mysql> ALTER USER ' root ' @ ' localhost ' identified by ' Oracle ';
9. Configuring the MySQL service self-start
[[email protected] ~]# cd/usr/local/mysql[[email protected] mysql]# CP support-files/mysql.server/etc/ Init.d/mysqld[[email protected] mysql]# chkconfig--add mysqld[[email protected] mysql]# chkconfig--list Mysqldmysqld 0:off 1:off 2:on 3:on 4:on & Nbsp;5:on 6:off
10. Close the MySQL database
[[email protected] bin]# mysqladmin-u root shutdownmysqladmin:connect to server at ' localhost ' failederror: ' Acces s denied for user ' root ' @ ' localhost ' (using password:no) ' [[email protected] bin]# mysqladmin-u root-p shutdownente R password:2016-10-06t05:50:46.469848z mysqld_safe mysqld from PID file/mysql/run/mysqld.pid ended[1]+ Done ; mysqld_safe--user=mysql
11. mysql start and stop through the service
[[email protected] bin]# service mysqld startstarting MySQL. , &NB Sp [ ok ][[email protected] bin]# service mysqld stopshutting down MySQL. , &NB Sp [ ok ]
12. Login to non-default port MySQL
[Email protected] bin]# mysql-u root-p8000-h localhost-penter password:welcome to the MySQL monitor. Commands End With; or \g.
MySQL 5.7.15 Compilation Installation