首先在配置文件里查看debian-sys-maint的密码
sudo cat /etc/mysql/debian.cnf
然后使用该用户登录:
mysql -udebian-sys-maint -p
use mysql;
update user set plugin="mysql_native_password";
alter user 'root'@'localhost' identified with mysql_native_password by '123456';
flush privileges;
会提示密码太简单,弄复杂一点就好了。