sudo /etc/init.d/MySQL stop
(可能有其它的方法,总之中止MySQLd的运行就能够了)mysql
在/etc/mysql/mysql.conf.d/mysqld.cnf
文件中添加skip-grant-tables
,每台电脑的文件位置可能不一样。sql
sudo /etc/init.d/MySQL start
spa
MySQL -u root
rest
update MySQL.user set password=PASSWORD('newpassword') where User='root';
flush privileges;
code
/etc/init.d/MySQL restart
ip
就能够使用新密码 newpassword 登陆了。it