1
停止mysql, 重启并绕过安全检测
sudo /etc/init.d/mysql stop
sudo mysqld_safe --skip-grant-tables &
2
如果出现'/var/run/mysqld' for UNIX socket file don't exists
mkdir -p /var/run/mysqld
chown mysql:mysql /var/run/mysqld
直到 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql
3
use mysql;
update user set authentication_string=PASSWORD("mynewpassword") where User='root';
flush privileges;
quit