安裝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