[ root@ctos3 ~]# cat /etc/redhat-release
CentOS Linux release 7.5.1804(Core)
https://dev.mysql.com/downloads/mysql/5.7.html#downloads
#1. Install related dependencies
yum install -y gcc gcc-c++ cmake ncurses ncurses-devel bison wget openssl-devel.x86_64
#2. Create users and groups
groupadd mysql
useradd mysql -s /sbin/nologin -M -g mysql
#3. Download mysql and decompress it, or download it and upload it using rz (package name lrzsz)
mkdir /home/demo/tools/
cd /home/demo/tools/
wget https://cdn.mysql.com//Downloads/MySQL-5.7/mysql-boost-5.7.29.tar.gz
tar xf mysql-boost-5.7.29.tar.gz
#4. Configure related parameters
[ root@ctos3 tools]# cd mysql-5.7.29/[root@ctos3 mysql-5.7.29]# pwd
/home/demo/tools/mysql-5.7.29[root@ctos3 mysql-5.7.29]# cmake -DCMAKE_INSTALL_PREFIX=/application/mysql -DMYSQL_DATADIR=/application/mysql/data -DMYSQL_UNIX_ADDR=/application/mysql/tmp/mysql.sock -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DWITH_BOOST=boost
DCMAKE_INSTALL_PREFIX #Specify the installation directory of the MySQL program
DMYSQL_DATADIR #Data file directory
DMYSQL_UNIX_ADDR #socket file path
DDEFAULT_CHARSET #Specify the server default character set, the default latin1
DDEFAULT_COLLATION #Specify the default collation rules of the server, the default latin1_general_ci
#5. Compile and install
[ root@ctos3 mysql-5.7.29]# make -j 2&& make install
#- The function of the j parameter: it will take up a lot of system resources when compiling. You can specify multiple compilation commands through the -j parameter to perform parallel compilation to improve the speed. Use the following command to view the number of system CPU cores
[ root@ctos3 ~]# cat /proc/cpuinfo | grep processor |wc -l
2
#6. Create data directory and modify permissions
[ root@ctos3 mysql-5.7.29]# mkdir /application/mysql/data #Store data directory
#7. Configure the /etc/my.cnf file
[ root@ctos3 ~]# cat /etc/my.cnf
[ mysqld]
port =3306
socket =/application/mysql/tmp/mysql.sock
user = mysql
basedir =/application/mysql
datadir =/application/mysql/data
pid-file =/application/mysql/data/mysql.pid
sql_mode='ONLY_FULL_GROUP_BY'
log_error =/application/mysql/mysql-error.log
! includedir /etc/my.cnf.d
[ client]
port =3306
socket =/application/mysql/tmp/mysql.sock
#8. Initialize the database
[ root@ctos3 support-files]# /application/mysql/bin/mysqld --initialize-insecure --user=mysql --basedir=/application/mysql --datadir=/application/mysql/data
#9. Generate service startup script
# Set environment variables
[ root@ctos3 support-files]# echo 'export PATH=/application/mysql/bin:$PATH'>>/etc/profile
[ root@ctos3 support-files]# source /etc/profile
[ root@ctos3 support-files]# tail -1/etc/profile
export PATH=/application/mysql/bin:$PATH
# Generate startup script
[ root@ctos3 ~]# cd /application/mysql/support-files/[root@ctos3 support-files]# ls
magic mysqld_multi.server mysql-log-rotate mysql.server
[ root@ctos3 support-files]# cp mysql.server /etc/init.d/mysqld
# Start service and set self-startup
[ root@ctos3 support-files]# /etc/init.d/mysqld start
Starting MySQL. SUCCESS![root@ctos3 support-files]# chkconfig --add mysqld
[ root@ctos3 support-files]# chkconfig mysqld on
#10. Log in to MySQL (login without a password)
[ root@ctos3 ~]# mysql -uroot -p
Enter password:
#11. View version
mysql> select version();+-----------+|version()|+-----------+|5.7.29|+-----------+1 row inset(0.00 sec)
#12. set password
mysql> update mysql.user set authentication_string=password('guoke123') where user='root';
Query OK,1 row affected,1warning(0.01 sec)
Rows matched:1 Changed:1 Warnings:1
mysql> flush privileges;
Query OK,0 rows affected(0.01 sec)
Recommended Posts