[root@VM-20-12-centos data]# wget https://dev.mysql.com/get/Downloads/MySQL-5.7/mysql-5.7.37-linux-glibc2.12-x86_64.tar.gz[root@VM-20-12-centos data]# tar -zxvf jdk-8u321-linux-x64.tar.gz
[root@VM-20-12-centos data]# tar -zxvf mysql-5.7.37-linux-glibc2.12-x86_64.tar.gz
[root@VM-20-12-centos data]# rm -rf mysql-5.7.37-linux-glibc2.12-x86_64.tar.gz
[root@VM-20-12-centos data]# mv mysql-5.7.37-linux-glibc2.12-x86_64 /usr/local/mysql
[root@VM-20-12-centos data]# mkdir mysql
[root@VM-20-12-centos data]# groupadd mysql && useradd -r -g mysql mysql
[root@VM-20-12-centos data]# chown mysql:mysql -R /data/mysql
[root@VM-20-12-centos data]# vim /etc/my.cnf
[mysqld]
bind-address=0.0.0.0
port=3306
user=mysql
basedir=/usr/local/mysql
datadir=/data/mysql
socket=/data/mysql/mysql.sock
character_set_server=utf8mb4
explicit_defaults_for_timestamp=true
symbolic-links=0
log-error=/data/mysql/mysql.log
pid-file=/data/mysql/mysql.pid
[root@VM-20-12-centos data]# cd /usr/local/mysql/bin
[root@VM-20-12-centos bin]# yum install -y libaio numactl
[root@VM-20-12-centos bin]# ./mysqld --defaults-file=/etc/my.cnf --basedir=/usr/local/mysql/ --datadir=/data/mysql/ --user=mysql --initialize
[root@VM-20-12-centos bin]# tail -1 /data/mysql/mysql.log
2022-03-10T07:59:19.612476Z 1 [Note] A temporary password is generated for root@localhost: Dprirkmhy5/t
[root@VM-20-12-centos bin]# cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysql
[root@VM-20-12-centos bin]# service mysql start
Starting MySQL. SUCCESS!
[root@VM-20-12-centos bin]# /usr/local/mysql/bin/mysql -u root -h 127.0.0.1 -pmysql> SET PASSWORD = PASSWORD('gemaolin125');Query OK, 0 rows affected, 1 warning (0.00 sec)mysql> ALTER USER 'root'@'localhost' PASSWORD EXPIRE NEVER;Query OK, 0 rows affected (0.00 sec)mysql> FLUSH PRIVILEGES;Query OK, 0 rows affected (0.00 sec)
Enter password:
mysql> SET PASSWORD = PASSWORD('123456');
Query OK, 0 rows affected, 1 warning (0.00 sec)mysql> ALTER USER 'root'@'localhost' PASSWORD EXPIRE NEVER;
Query OK, 0 rows affected (0.00 sec)mysql> FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.00 sec)