目录

Ubuntu-20.04-mysql-8-默认密码问题

Ubuntu 20.04 + mysql 8 默认密码问题

问题描述:

Ubuntu20.04安装完mysql8之后无法登录,不知道密码

mysql -u root 

原因:

系统默认自动配置好了用户和强密码

解决办法:

sudo cat /etc/mysql/debian.cnf

查看该文件

https://i-blog.csdnimg.cn/img_convert/aadcc69ae906afd01d6440389720e498.png

利用上面的user 和 passwd 即可登录mysql

mysql -u(user) -p(passwd) 

随后修改密码

进入mysql后执行以下命令:

use mysql; 
 
update user set authentication_string='' where user='root';      
 
alter user 'root'@'localhost' identified with mysql_native_password by 'xxx';     #修改密码为xxx

退出后即可正常登录

mysql -u root -p