MySQL 错误【二】: Access denied for user ‘root‘@‘localhost‘ (using password: YES) 解决办法
注:
- 管理员下运行 cmd
- bin 目录下
-
在 my.ini 下添加
skip-grant-tables
, 可免密登录
-
设置密码
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)
host:确定要操作的数据库在哪台电脑上,比如上图的localhost代表的是本机,如果要操作的是别人的电脑,就需要输入其他的IP地址
- 注掉
skip-grant-tables
- 重启 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 服务已经启动成功。
- 回到 Navicat 输入密码即成功解决
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 无需6万激活码!GitHub神秘组织3小时极速复刻Manus,手把手教你使用OpenManus搭建本
· C#/.NET/.NET Core优秀项目和框架2025年2月简报
· Manus爆火,是硬核还是营销?
· 一文读懂知识蒸馏
· 终于写完轮子一部分:tcp代理 了,记录一下