yum remove mysql-libs
按照依赖关系依次安装 rpm 包,依赖关系依次为 common→libs→client→server。使用命令rpm -ivh {-file-name}进行安装操作。
[root@node01 mysql]# rpm -ivh mysql-community-common-5.7.36-1.el7.x86_64.rpm
warning: mysql-community-common-5.7.36-1.el7.x86_64.rpm: Header V3 DSA/SHA256 Signature, key ID 5072e1f5: NOKEY
Preparing... ################################# [100%]
Updating / installing...
1:mysql-community-common-5.7.36-1.e################################# [100%]
[root@node01 mysql]# rpm -ivh mysql-community-libs-5.7.36-1.el7.x86_64.rpm
warning: mysql-community-libs-5.7.36-1.el7.x86_64.rpm: Header V3 DSA/SHA256 Signature, key ID 5072e1f5: NOKEY
Preparing... ################################# [100%]
Updating / installing...
1:mysql-community-libs-5.7.36-1.el7################################# [100%]
[root@node01 mysql]# rpm -ivh mysql-community-client-5.7.36-1.el7.x86_64.rpm
warning: mysql-community-client-5.7.36-1.el7.x86_64.rpm: Header V3 DSA/SHA256 Signature, key ID 5072e1f5: NOKEY
Preparing... ################################# [100%]
Updating / installing...
1:mysql-community-client-5.7.36-1.e################################# [100%]
[root@node01 mysql]# systemctl start mysqld
[root@node01 mysql]# systemctl status mysqld
● mysqld.service - MySQL Server
Loaded: loaded (/usr/lib/systemd/system/mysqld.service; enabled; vendor preset: disabled)
Active: active (running) since Fri 2023-11-03 14:20:11 CST; 25s ago
Docs: man:mysqld(8)
http://dev.mysql.com/doc/refman/en/using-systemd.html
Process: 69987 ExecStart=/usr/sbin/mysqld --daemonize --pid-file=/var/run/mysqld/mysqld.pid $MYSQLD_OPTS (code=exited, status=0/SUCCESS)
Process: 67928 ExecStartPre=/usr/bin/mysqld_pre_systemd (code=exited, status=0/SUCCESS)
Main PID: 69990 (mysqld)
Tasks: 27
Memory: 306.4M
CGroup: /system.slice/mysqld.service
└─69990 /usr/sbin/mysqld --daemonize --pid-file=/var/run/mysqld/mysqld.pid
查看密码如下
[root@node01 mysql]# grep password /var/log/mysqld.log
2023-11-03T06:20:07.838988Z 1 [Note] A temporary password is generated for root@localhost: e0,upedlUra)
[root@node01 mysql]# mysql -uroot -p -S /var/lib/mysql/mysql.sock
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 4
Server version: 5.7.36
输入上面生成的临时密码。
mysql> set password=password('1qaz#EDC') ;
Query OK, 0 rows affected, 1 warning (0.00 sec)
mysql> flush privileges ;
Query OK, 0 rows affected (0.00 sec)
mysql> exit
Bye