MySQL 错误【二】: Access denied for user ‘root‘@‘localhost‘ (using password: YES) 解决办法

  1. 在 my.ini 下添加 skip-grant-tables, 可免密登录
    在这里插入图片描述

  2. 设置密码

D:\mysql-5.7.35\bin>net start mysql
MySQL 服务正在启动 .
MySQL 服务已经启动成功。

D:\mysql-5.7.35\bin>mysql -u root -p
Enter password:   # 此处直接回车,不输入密码
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.7.35 MySQL Community Server (GPL)

Copyright (c) 2000, 2021, 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> update mysql.user set authentication_string=password('123456') where user='root' and Host ='localhost';
Query OK, 1 row affected, 1 warning (0.00 sec)
Rows matched: 1  Changed: 1  Warnings: 1

mysql> flush privileges;
Query OK, 0 rows affected (0.01 sec)

  1. 注掉 skip-grant-tables
    在这里插入图片描述
  2. 重启 MySQL 即可
mysql> exit
Bye

D:\mysql-5.7.35\bin>net stop mysql
MySQL 服务正在停止.
MySQL 服务已成功停止。


D:\mysql-5.7.35\bin>net start mysql
MySQL 服务正在启动 .
MySQL 服务已经启动成功。
  1. 回到 Navicat 输入密码即成功解决
    在这里插入图片描述

猜你喜欢

转载自blog.csdn.net/weixin_46644403/article/details/121898845
今日推荐