'Access denied for user 'root'@'localhost'

我在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

你可能感兴趣的:(linux,mysql,职场,denied,休闲)