1. Depend on the environment
yum install gcc gcc-c++ autoconf automake zlib* libxml* ncurses-devel libmcrypt* libtool* cmake
2. Create the mysql installation directory and data storage directory
#mkdir mysql/data
#mkdir mysql/software
3. Create mysql users and user groups
#useradd -g mysql create user group
4. Grant permission to the directory where the data is stored
Mysql CD /zyouke/mysql/ Go to the mysql data directory and compilation directory chown -r root:mysql.
5. Download and unpack it
Wget wget HTTP: / / http://downloads.sourceforge.net/project/boost/boost/1.59.0/boost_1_59_0.tar.gz https://mirrors.sohu.com/mysql/MySQL-5.7/mysql-5.7.28.tar.gz tar – ZVXF mysql – 5.7.28. Tar. Gz tar – ZVXF boost_1_59_0. Tar. Gz
6. Compile
#cmake -DCMAKE_INSTALL_PREFIX=/zyouke/mysql/software \
-DMYSQL_UNIX_ADDR=/tmp/mysqld.sock \
-DDEFAULT_CHARSET=utf8 \
-DDEFAULT_COLLATION=utf8_general_ci \
-DWITH_EXTRA_CHARSETS:STRING=utf8,gbk \
-DWITH_MYISAM_STORAGE_ENGINE=1 \
-DWITH_INNOBASE_STORAGE_ENGINE=1 \
-DWITH_MEMORY_STORAGE_ENGINE=1 \
-DWITH_READLINE=1 \
-DDOWNLOAD_BOOST=1 \
-DWITH_BOOST=/zyouke/mysql/boost_1_59_0 \
-DENABLED_LOCAL_INFILE=1 \
-DMYSQL_DATADIR=/zyouke/mysql/data \
-DMYSQL_USER=mysql \
-DMYSQL_TCP_PORT=3306
#make
#make install
Copy the code
7. Initialize the database
Note that the current version needs to customize my3306.cnf, and the previous my-default. CNF does not exist, then add the attributes to be added
#cd /zyouke/mysql/software/bin
./mysqld --defaults-file=/zyouke/mysql/software/support-files/my3306.cnf --initialize --user=mysql --datadir=/zyouke/mysql/data/3306 --basedir=/zyouke/mysql/software
Copy the code
The passwords marked in red are random passwords generated by the current version, which will be used in future password changes
CNF: /zyouke/mysql/data/3307: /zyouke/mysql/data/3307: /zyouke/mysql/data/3307: /zyouke/mysql/data/3307: /zyouke/mysql/data/3307: /zyouke/mysql/data/3307: Initialize database 3307 in the same way as initializing database 3306
8. Start the database
#cd /zyouke/mysql/software/bin
#./mysqld_safe --defaults-file=/zyouke/mysql/software/support-files/my3306.cnf &
Copy the code
9. The connection
Since the default password for mysql 5.7 is random, this section does not cover how to obtain a random password and how to avoid entering a password. Add it to the mysql configuration fileskip-grant-tablesParameters.
#/zyouke/mysql/software/bin
#./mysql -uroot -p
Copy the code
10. Change the password and remote connection permission of user root
alter user ‘root’@’localhost’ identified by ‘mysql123456’;
flush privileges;
GRANT ALL PRIVILEGES ON . TO ‘root’@’%’ IDENTIFIED BY ‘mysql123456’ WITH GRANT OPTION;
flush privileges;