一、查看密碼
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