1. Installation Dependencies
Yum install-y cmake Bison bison-devel libaio-devel gcc gcc-c++ git ncurses-devel
wget https://dev.mysql.com/get/Downloads/MySQL-5.7/mysql-5.7.20.tar.gz
wget https://zh.osdn.net/projects/sfnet_boost/downloads/boost/1.59.0/boost_1_59_0.tar.gz/
2. Unzip the build installation
[Email protected] ~]# Tar XF mysql-5.7.20.tar.gz
[Email protected] ~]# MV boost_1_59_0.tar.gz mysql-5.7.20
[Email protected] ~]# CD mysql-5.7.20
[Email protected] mysql-5.7.20]# mkdir Configure
[Email protected] mysql-5.7.20]# CD Configure
[Email protected] configure]# CMake. -dbuild_config=mysql_release \
-dinstall_layout=standalone \
-dcmake_build_type=relwithdebinfo \
-denable_dtrace=off \
-dwith_embedded_server=off \
-dwith_innodb_memcached=on \
-dwith_ssl=bundled \
-dwith_zlib=system \
-dwith_pam=on \
-dcmake_install_prefix=/var/mysql/\
-dinstall_plugindir= "/var/mysql/lib/plugin" \
-ddefault_charset=utf8 \
-DDEFAULT_COLLATION=UTF8_GENERAL_CI \
-dwith_editline=bundled \
-dfeature_set=community \
-dcompilation_comment= "MySQL Server (GPL)" \
-dwith_debug=off \
-dwith_boost=.
[[email protected] configure]# make
[[email protected] configure]# make install # This step is slow
3. Create profile directory and user
[[email protected] ~]# useradd-s/sbin/nologin MySQL
[Email protected] ~]# mkdir-p/data/mysql
[Email protected] ~]# mkdir-p/var/mysql/log
[Email protected] ~]# chown-r mysql:mysql/data/mysql/
[Email protected] ~]# chown-r Mysql:mysql/var/mysql/log
4. Modify the configuration file
[Email protected] ~]# VIM/ETC/MY.CNF
...
[Mysqld]
Datadir=/data/mysql
Socket=/var/lib/mysql/mysql.sock
Log_error=/var/mysql/log/error.log
Basedir=/var/mysql
5. Initialization
[Email protected] ~]#/var/mysql/bin/mysqld--initialize--user=mysql
[Email protected] ~]# ll/data/mysql/
Total 110628
-rw-r-----. 1 MySQL MySQL 17:51 auto.cnf
-rw-r-----. 1 mysql mysql 419 Jul 17:51 Ib_buffer_pool
-rw-r-----. 1 mysql mysql 12582912 Jul 17:51 ibdata1
-rw-r-----. 1 mysql mysql 50331648 Jul 17:51 ib_logfile0
-rw-r-----. 1 mysql mysql 50331648 Jul 17:51 ib_logfile1
Drwxr-x---. 2 mysql mysql 4096 Jul 17:51 MySQL
Drwxr-x---. 2 mysql mysql 8192 Jul 17:51 performance_schema
Drwxr-x---. 2 mysql mysql 8192 Jul 17:51 sys
[Email protected] ~]# ll/var/mysql/log/
Total 4
-rw-r-----. 1 MySQL MySQL 802 Jul 17:51 Error.log
6. Modify the configuration file
[Email protected] ~]# Cp/var/mysql/support-files/mysql.server/etc/init.d/mysqld
[Email protected] ~]# vim/etc/init.d/mysqld #找到如下两行
...
basedir=/var/mysql/
Datadir=/data/mysql
...
[Email protected] ~]# mkdir-p/var/lib/mysql
[Email protected] ~]# chown-r mysql:mysql/var/lib/mysql
7. Add Environment variables
[Email protected] mysql]# Vim/etc/profile
...
mysql_home=/var/mysql/bin/
Path= $PATH: $MYSQL _home
[Email protected] ~]# Source/etc/profile
8. Modify the original password
[Email protected] ~]# Cat/var/mysql/log/error.log | grep generated
2018-07-10t09:51:31.365809z 1 [Note] A temporary password is generated for [email protected]: ps:scg1gophj
[[email protected] ~]#/etc/init.d/mysqld start
[Email protected] ~]# ln-s/var/lib/mysql/mysql.sock/tmp/
[Email protected] ~]# mysql-uroot-p
The password is: ps:scg1gophj
mysql> alter user ' root ' @ ' localhost ' identified by ' 123123 ';
Query OK, 0 rows Affected (0.00 sec)
mysql> flush Privileges;
Query OK, 0 rows Affected (0.00 sec)
centos7.4 MySQL 5.7.20 source installation