查看用户名和密码
sudo cat /etc/mysql/debian.cnf
强行登录,就是使用生成的密码登录
mysql -u debian-sys-maint -p
修改密码
use mysql;
// 下面这句命令有点长,请注意。
update mysql.user set authentication_string=password('root') where user='root' and Host ='localhost';
update user set plugin="mysql_native_password";
flush privileges;
quit;
重启mysql
sudo service mysql restart
mysql -u root -p // 启动后输入已经修改好的密码:root
文章评论