问题
mysql8遇到ERROR 1045 (28000): Access denied for user ‘root’@‘localhost’ (using passwor:yes)问题
原因
说白了就是密码错误,本文直接进行修改用户密码。其他方法不做解释。
解决流程
1、跳过验证
找到my.ini或者my.conf,在[mysqld]后任意一行加入:
skip-grant-tables
重启mysql。
2、进入数据库进行修改
输入密码时,直接回车即可。
[root@imageserver ~]# mysql -u root -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 7
Server version: 8.0.20 Source distribution
Copyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved.
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>
进入mysql数据库中:
mysql> use mysql;
Database changed
mysql>
修改密码:
mysql> update user set authentication_string="123" where user='root';
Query OK, 1 row affected (0.09 sec)
Rows matched: 1 Changed: 1 Warnings: 0
mysql> flush privileges;
Query OK, 0 rows affected (0.06 sec)
mysql> quit
Bye
[root@imageserver ~]#
3、关闭跳过验证
注释掉跳过验证那一行即可。
随后重启mysql。
4、重新进入数据库进行测试
有其他交流的想法,可以加我创建的Q群:820080257