1045 - Access denied for user 'root'@'localhost' (using password: NO)1045 -拒绝访问用户'root'@'localhost'(使用密码:NO)
时间: 2023-12-11 09:33:54 浏览: 95
这个错误通常是由于使用了错误的用户名或密码,或者没有为用户授予正确的权限。以下是一些可能的解决方法:
1. 确保您使用的是正确的用户名和密码。如果您不确定,请尝试重置密码或创建新用户。
2. 确保您为用户授予了正确的权限。您可以使用以下命令为用户授予所有权限:
```mysql
GRANT ALL PRIVILEGES ON *.* TO 'root'@'localhost' IDENTIFIED BY 'password' WITH GRANT OPTION;
```
其中,'root'是用户名,'localhost'是主机名,'password'是密码。请根据您的情况进行更改。
3. 如果您正在使用远程连接,请确保您的MySQL服务器允许远程连接。您可以通过编辑MySQL配置文件来启用远程连接:
```shell
sudo vi /etc/mysql/mysql.conf.d/mysqld.cnf
```
找到以下行:
```shell
bind-address = 127.0.0.1
```
将其更改为:
```shell
bind-address = 0.0.0.0
```
然后重启MySQL服务:
```shell
sudo service mysql restart
```
这将允许来自任何IP地址的远程连接。
4. 如果您仍然无法解决问题,请尝试卸载并重新安装MySQL服务器。在卸载之前,请备份您的数据库以防止数据丢失。
阅读全文
相关推荐


















