解决ubuntu下mysql的'Access denied for user 'root'@'localhost' (using password: YES)'

解决ubuntu下mysql的'Access denied for user 'root'@'localhost' (using password: YES)'

一般出现这种情况,只要重新修改下root密码

解决方法:
1.打开/etc/mysql/debian.cnf文件,里面存储了系统管理员的密码

2. 输入命令:

mysql -udebian-sys-maint -p

再输入对应debian.cnf里对应的密码,以管理员身份进去

3.进入控制台后.按以下步骤进行:

use mysql;update user set password=PASSWORD('新密码') where user='root';FLUSH PRIVILEGES;

如果你的mysql是5.7版本后的  

password字段已经改成authentication_string这个字段了,那就输入
update user set 
authentication_string=PASSWORD('新密码') where user='root';
此时可以输入quit;退出后用root帐号登录了

猜你喜欢

转载自blog.csdn.net/qq_15905107/article/details/81301705
今日推荐