当前位置:Gxlcms > mysql > mysqlAccessdeniedforuser''@'localhost'todatabase_MySQL

mysqlAccessdeniedforuser''@'localhost'todatabase_MySQL

时间:2021-07-01 10:21:17 帮助过:18人阅读

bitsCN.com

安装Mysql后在终端输入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

bitsCN.com

人气教程排行