linux下为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

 

原文内容:http://bbs.linuxpk.com/thread-22953-1-6.html

感谢Suse

你可能感兴趣的:(数据库,Linux)