/sbin/service mysqld stop (Redhat&Centos)
mysqld_safe –skip-grant-tables &
mysql
use mysql
UPDATE user SET password=PASSWORD(‘新密码‘) WHERE user=’root’;
FLUSH PRIVILEGES;
quit
killall -9 mysqld_safe; killall -9 mysqld
/sbin/service mysqld start
mysql -uroot -p
输入密码
在输入一次 成功登录的话 就是对了