错误:'访问被拒绝用户&root;' @' localhost' (使用密码:是)'

时间:2014-07-13 00:04:30

标签: mysql

/etc/init.d/mysqld stop
mysqld_safe --skip-grant-tables &
mysql -u root
mysql> use mysql;
mysql> update user set password=PASSWORD("newrootpassword") where User='root';
mysql> flush privileges;
mysql> quit
/etc/init.d/mysqld stop
/etc/init.d/mysqld start

我已经尝试了以上无济于事。

我正在编辑/etc/my.cnf文件,当我注意到这个问题时,我又回到了编辑之前的备份。

问题仍然存在。问题是什么?

这些是我运行的命令,我认为可能导致了这个问题:

mysql> update db set Host='myip' where Db='mydb';
mysql> update user set Host='myip' where user='root';

请注意,访问phpMyAdmin时没有问题。

1 个答案:

答案 0 :(得分:0)

mysql> update db set Host='localhost' where Db='mydb';
mysql> update user set Host='localhost' where user='root';
mysql> flush privileges;

如果您连接到localhost,主机必须是localhost,而不是您的IP而不是您的服务器IP。

您还可以使用通配符%