MySqlException: Access denied for user 'root'@'WIN-5CPRGIDONEU' (using password: YES)
时间: 2023-09-11 19:09:14 浏览: 145
这个错误是由于使用了错误的密码导致访问MySQL数据库时被拒绝所引起的。解决这个问题的方法是重置密码。以下是重置MySQL密码的步骤:
1. 打开MySQL的安装路径,找到配置文件my.ini,在[mysqld]后面添加如下内容:
```
skip-grant-tables
```
2. 以管理员权限打开命令提示符(cmd),停止MySQL服务:
```
net stop mysql
```
3. 使用cmd命令进入MySQL安装路径下的bin文件夹中:
```
cd C:\Program Files\MySQL\MySQL Server X.X\bin
```
4. 进入数据库并使用以下命令重置密码(不需要输入密码):
```
mysql -u root -p
```
5. 在MySQL中执行以下命令将密码置空:
```
use mysql;
update user set authentication_string='' where user='root';
flush privileges;
```
6. 设置新密码并授权:
```
ALTER USER 'root'@'localhost' IDENTIFIED BY '新密码' PASSWORD EXPIRE NEVER;
alter user 'root'@'localhost' identified by '新密码';
grant all privileges on *.* to "root"@'localhost';
flush privileges;
```
7. 保存并关闭配置文件。
8. 重新启动MySQL服务:
```
net start mysql
```
这样,你应该能够成功重置MySQL的密码并解决该问题。请确保将上述步骤中的"新密码"替换为你想要设置的新密码。<span class="em">1</span><span class="em">2</span><span class="em">3</span>
#### 引用[.reference_title]
- *1* [服务器mysql报错:Error: Access denied for user ‘root‘@‘localhost‘ (using password: YES)](https://blog.csdn.net/weixin_45341014/article/details/125447980)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 33.333333333333336%"]
- *2* [spring boot整合mybatis连接不上数据库](https://download.csdn.net/download/weixin_38623000/13685882)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 33.333333333333336%"]
- *3* [Access denied for user root @ localhost (using password: YES)](https://blog.csdn.net/weixin_67925067/article/details/129630161)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 33.333333333333336%"]
[ .reference_list ]
阅读全文