1.查看当前密码:sudo cat /root/.mysql_secret
2.登陆:mysql -uroot -p 提示密码时输入上条命令cat出来的密码,成功登陆mysql
3.通过mysql命令修改密码:alter user 'root'@'localhost' identified by ’登陆进来的密码’;
4.update mysql.user set authentication_string=password('您的密码') where user='root' and Host='localhost';
5.写入:flush privileges;
6.退出quit