First, download the source Code compilation tool:
Yum-y install \
GCC \
gcc-c++ \
Make \
ncurses \
Ncurses-devel \
Bison \
CMake
second, compile and install
1. Create a running user
Useradd-s/sbin/nologin MySQL//manually build an account
2. Unpacking
Transfer the package into Linux
Tar XF mysql-boost-5.7.20.tar.gz-c/opt///Unzip the directory to be large enough, or it will be an error
cd/opt/mysql-5.7.20/
3. Configuration:
CMake \
-DCMAKE_INSTALL_PREFIX=/USR/LOCAL/MYSQL \//Specifies that the MySQL database program be installed in a directory
-dmysql_unix_addr=/usr/local/mysql/mysql.sock \//Specify the path of the sock file
-DSYSCONFDIR=/ETC \//Specify initialization parameter file directory
-dsystemd_pid_dir=/usr/local/mysql \
-DDEFAULT_CHARSET=UTF8 \//Specifies the character set encoding used by default
-DDEFAULT_COLLATION=UTF8_GENERAL_CI \//Specifies the character set collation rules used by default
-dwith_innobase_storage_engine=1 \
-dwith_archive_storage_engine=1 \
-dwith_blackhole_storage_engine=1 \
-dwith_perfschema_storage_engine=1 \
-dmysql_datadir=/usr/local/mysql/data \
-dwith_boost=boost \
-dwith_systemd=1
4. Compiling and installing
Make && make install
Third, after installation adjustment
1. Set permissions on the database directory
Chown-r mysql:mysql/usr/local/mysql/
2. Setting up the configuration file
VI/ETC/MY.CNF//Original Delete Insert new
[Client]
Port = 3306
Default-character-set=utf8
Socket =/usr/local/mysql/mysql.sock
[MySQL]
Port = 3306
Default-character-set=utf8
Socket =/usr/local/mysql/mysql.sock
[Mysqld]
user = MySQL
Basedir =/usr/local/mysql
DataDir =/usr/local/mysql/data
Port = 3306
Character_set_server=utf8
Pid-file =/usr/local/mysql/mysqld.pid
Socket =/usr/local/mysql/mysql.sock
Server-id = 1
Sql_mode=no_engine_substitution,strict_trans_tables,no_auto_create_user,no_auto_value_on_zero,no_zero_in_date, No_zero_date,error_for_division_by_zero,pipes_as_concat,ansi_quotes//fixed format
: X
Chown mysql:mysql/etc/my.cnf
3. Setting Environment variables
Echo ' path=/usr/local/mysql/bin:/usr/local/mysql/lib: $PATH ' >>/etc/profile//Add these two paths to the environment variable, and put it in the profile file to start from running, otherwise does not take effect
echo ' Export PATH ' >>/etc/profile//can also be soft link
Source/etc/profile//Immediate effect
4. Initialize the database
cd/usr/local/mysql/
BIN/MYSQLD \
--initialize-insecure \
--user=mysql \
--basedir=/usr/local/mysql \
--datadir=/usr/local/mysql/data//mysql Initialization
5. Adding system Services
CP usr/lib/systemd/system/mysqld.service/usr/lib/systemd/system/
Systemctl Daemon-reload
Systemctl start mysqld//Start database
NETSTAT-ANPT | grep 3306
Systemctl Enable MYSQLD//start-up
6. Set Data password
mysqladmin-u root-p Password "123"//Set password for root account
7. Login Database
Mysql-u root-p//Database login is successful, it can be operated inside
MySQL database source code compilation installation