方法一:
1) cd /var/lib/mysql
2) rm -rf mysql
3) /etc/init.d/mysqld restart
4) 重新设置密码:
echo "grant all on *.* to identified by '123456';" | mysql -uroot
echo "grant all on *.* to identified by '123456';" | mysql -uroot -p123456方法二:
1) service mysqld stop
2) 使用跳过权限检查的方式启动MySQL:
/usr/bin/mysqld_safe --skip-grant-tables &
3) 重新设置密码:
echo "grant all on *.* to identified by '123456';" | mysql -uroot
echo "grant all on *.* to identified by '123456';" | mysql -uroot -p123456