文章目录
linux 等保问题整改,MySQL升级 或者安装 查看临时密码报错。
linux 等保问题整改,MySQL升级 或者安装 查看临时密码报错。
问题:
Oracle MySQL Server 输入验证错误漏洞(CVE-2022-21367)
Oracle MySQL Server 输入验证错误漏洞(CVE-2022-21344)
Oracle MySQL 输入验证错误漏洞(CVE-2022-21417)
一、安装完MySQL数据库查看临时密码有两个
[root@localhost mysql5.7.38]# grep 'temporary password' /var/log/mysqld.log
2020-10-22T11:42:49.649516Z 1 [Note] A temporary password is generated for root@localhost: iIQuf,Ody3,*
2022-04-25T10:55:25.648438Z 1 [Note] A temporary password is generated for root@localhost: 4NyO_/g)K:7k
二、登录报错:
[root@localhost mysql5.7.38]# grep 'temporary password' /var/log/mysqld.log
2020-10-22T11:42:49.649516Z 1 [Note] A temporary password is generated for root@localhost: iIQuf,Ody3,*
2022-04-25T10:55:25.648438Z 1 [Note] A temporary password is generated for root@localhost: 4NyO_/g)K:7k
[root@localhost mysql5.7.38]# mysql -uroot -p
Enter password:
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)
[root@localhost mysql5.7.38]# mysql -uroot -p
Enter password:
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)
[root@localhost mysql5.7.38]#
三、登录报错截图MySQL
四、解决方法:
第一步:添加skip-grant-tables,重启mysqld服务。设置密码为空。
[root@localhost mysql5.7.38]# vim /etc/my.cnf
vi /etc/my.cnf
skip-grant-tables
:wq
systemctl restart mysqld
mysql -uroot -p
use mysql;
update mysql.user set authentication_string=password('') where user='root'and Host ='localhost';
flush privileges;
quit;
第二步:删除skip-grant-tables,重启mysqld服务。
vi /etc/my.cnf
# 注释掉
#skip-grant-tables
# 光标移动到所在行 按dd
dd skip-grant-tables
:wq
systemctl restart mysqld
mysql -uroot -p
第三步:设置密码root密码,开启远程登录。
[root@localhost mysql5.7.38]# mysql -uroot -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 3
Server version: 5.7.38 MySQL Community Server (GPL)
Copyright (c) 2000, 2022, Oracle and/or its affiliates.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> set global validate_password_policy=0;
Query OK, 0 rows affected (0.00 sec)
mysql> set global validate_password_length=4;
Query OK, 0 rows affected (0.00 sec)
mysql> set password for root@localhost=password('123456');
Query OK, 0 rows affected, 1 warning (0.00 sec)
mysql> grant all privileges on *.* to root@'%' identified by '123456 ';
Query OK, 0 rows affected, 1 warning (0.00 sec)
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
mysql> exit
Bye
[root@localhost mysql5.7.38]#
五、登录成功
[root@localhost mysqldata]# mysql -uroot -p123456
mysql: [Warning] Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 83
Server version: 5.7.38-log MySQL Community Server (GPL)
Copyright (c) 2000, 2022, Oracle and/or its affiliates.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| sys |
+--------------------+
11 rows in set (0.00 sec)
六、安装升级请看我写的文章 。
文章:
备份全库
然后在恢复就可以