Ubuntu20.04 安装 mysql8.0 之后 root 账户无法登录

一、查看密码

sudo cat /etc/mysql/debian.cnf

二、利用 debian-sys-maint 账户登录Mysql

mysql -udebian-sys-maint -p

三、查看user表信息:

use mysql;
select user,host,authentication_string from user;

可以明显看到,root账户存在但密码为空。

四、修改密码:

alter user 'root'@'localhost' identified with mysql_native_password by 'mysql'; # 修改密码为 mysql
flush privileges; # 重新加载权限表

五、退出mysql重新登录

quit;
mysql -uroot -p

posted @ 2020-07-27 15:01  予之路  阅读(927)  评论(0编辑  收藏  举报