mysql5.7登录 Access denied for user 'root'@'localhost' (using password: NO)
时间: 2023-11-15 22:58:25 浏览: 36
这个报错是因为你在没有输入密码的情况下尝试使用root用户登录mysql5.7,而mysql5.7默认需要密码认证才能登录。解决这个问题的方法有两种:
1.使用正确的密码登录。
2.如果忘记密码,可以通过跳过登录并修改密码的方式来重置mysql的root用户密码。具体步骤如下:
1)先关闭正在运行的MySQL服务。
2)打开cmd窗口,转到mysql\bin目录。
3)输入mysqld --skip-grant-tables 回车。--skip-grant-tables 的意思是启动MySQL服务的时候跳过权限表认证。
4)再开一个cmd窗口,转到mysql\bin目录下。
5)输入mysql回车,如果成功,将出现MySQL提示符 >。
6)连接权限数据库: use mysql;
7)改密码:update user set authentication_string=password('you new password') where user='root';(别忘了最后加分号)
8)刷新权限(必须步骤):flush privileges;
9)退出 quit。
10)再重新进入系统,使用用户名root和刚才设置的新密码登录。
--相关问题--:
相关问题
linuxmysql5.7Access denied for user 'root'@'localhost' (using password: YES)
引用中提到的错误是"Access denied for user 'root'@'localhost' (using password: YES)",这通常表示在使用密码登录MySQL时出现了权限问题。解决这个问题的方法有以下几种:
1. 使用引用中的方法来修改root用户的密码。首先,使用以下命令登录MySQL:use mysql;然后,执行以下命令来更新密码:update user set authentication_string=password('新密码') where user='root' and Host='localhost';最后,执行flush privileges;命令来刷新权限。这种方法需要保证你知道root用户的当前密码。
2. 使用引用中的方法来修改root用户的密码。首先,通过在MySQL配置文件中添加skip-grant-tables参数来跳过权限验证步骤。然后,启动MySQL服务。接下来,使用以下命令登录MySQL:use mysql;然后,执行以下命令来更新密码:update user set password = password('新密码') where user = 'root';最后,重启MySQL服务。这种方法适用于忘记了root用户的当前密码。
请注意,使用root用户访问MySQL是非常敏感的操作,请确保你遵循安全措施并保护好你的密码。<span class="em">1</span><span class="em">2</span><span class="em">3</span>
#### 引用[.reference_title]
- *1* *2* [关于MYSQL5.7: Access denied for user root@localhost (using password:YES)解决](https://blog.csdn.net/qq_36791569/article/details/81386197)[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: 50%"]
- *3* [连腾讯云上的docker上的mysql报错ERROR 1045 (28000): Access denied for user ‘root’@’localhost’ ...](https://download.csdn.net/download/weixin_38732519/14074606)[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: 50%"]
[ .reference_list ]
mysql5.7 Access denied for user 'root'@'localhost' (using password: YES)
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)这个错误通常表示在尝试连接到MySQL数据库时,使用的用户名和密码不正确。根据提供的引用内容,您可以尝试以下解决方法:
- 您可以使用mysql.user表更新root用户的密码,确保密码与您尝试连接时提供的密码一致。
- 您可以查看mysqld.cnf文件,确认该文件中的配置是否正确,并检查是否存在其他配置文件可能会覆盖您的更改。
- 您还可以尝试重启MySQL服务器,以确保任何更改都得到正确应用。
您可以尝试执行以下步骤:
1. 打开mysql命令行客户端。
2. 使用以下命令连接到MySQL服务器: mysql -u root -p
3. 输入您的密码,如果密码正确并且您仍然无法登录,则继续以下步骤。
4. 使用以下命令更新root用户的密码: update mysql.user set authentication_string=password('your_new_password') where user='root' and Host = 'localhost';
5. 刷新权限表: flush privileges;
6. 退出mysql命令行客户端: exit;
7. 尝试使用新密码重新连接到MySQL服务器。
请注意,您需要将"your_new_password"替换为您想要设置的新密码。如果您仍然遇到问题,请检查mysqld.cnf文件以及其他可能影响连接的配置文件。
相关推荐
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)