红联Linux门户
Linux帮助
当前位置: 红联Linux门户 > SuSE

Suse中出错Access denied for user ''@'localhost' to database

发布时间:2007-11-22 01:02:46来源:红联作者:NetFlow
好久没有用MySQL了,上次因为装了Banq的论坛系统,在用MySQL Administrator进去的时候竟然提示mysql error number 1045 access denied for user 'admin'@'localhost' (using password: YES)的错误,看来密码是对了,用户名错了,最后发现自己竟然犯了个第几错误,用户名应该是root,唉!

同时找了别人的资料,一起发上来,供下次使用。

Access denied for user ''@'localhost' to database

我在Suse Linux 10.2下用自带光盘用Yast2安装Mysql 5.0, 装好后在终端输入mysql, mysql
成功启动,退出,再输入 mysqladmin -u root password XXXXX, 出现错误: mysqladmin: connect to server at 'localhost' failed
error: 'Access denied for user 'root'@'localhost' (using password: NO)'

如先输入mysql,成功启动后输入use mysql,出现如下错误:Access denied for user ''@'localhost' to database 'mysql'

还有,输mysql可以,输mysql -u root就出错了:
Access denied for user 'root'@'localhost' (using password: NO).

The reason is:
是昨日更新ROOT密码时出错
update user set password = '123456' where user ="root" //这样写是错的,密码其实不是123456
应该为update user set password = password ('123456') where user = "root"

具体操作步骤:
关闭mysql:
# service mysqld stop
然后:
# mysqld_safe --skip-grant-tables
启动mysql:
# service mysqld start
mysql -u root
mysql> use mysql
mysql> UPDATE user SET Password=PASSWORD('xxx') WHERE user='root';
mysql> flush privileges;
mysql>\q

That's it. I hope those above could do a little favor for you!
文章评论

共有 0 条评论