关闭MYSQL服务

service mysqld stop

启动mysqld_safe ,跳过启动授权表。

mysqld_safe --skip-grant-tables &

登录mysql,并修改密码

mysql
use mysql
update user set password=PASSWORD('12345678') where user="root"; ---将root密码设置为12345678
flush privileges;
exit

关掉mysqld_safe进程

kill -9  11283  (11283为mysqld_safe进程)
service mysqld start
mysql -uroot -p (输入密码12345678即可)