首先使用update把mysql.user中的root的host从localhost修改成%:
/usr/local/mysql/bin/mysql -u root -p
mysql>use mysql;
mysql>update user set host='%' where user ='localhost';
mysql>flush privileges;
mysql>exit


修改了后在服务器用phpmyadmin连不上,显示:ERROR 1045 (28000): Access denied for user 'root'@'localhost' .... Error: Access denied for user 'root'@'localhost' (using password: YES)

解决方法,如下:

方法一:
# /etc/init.d/mysql stop
# mysqld_safe --user=mysql --skip-grant-tables --skip-networking &
# mysql -u root mysql
mysql> UPDATE user SET Password=PASSWORD('newpassword') where USER='root';
mysql> quit

其中不要输入:mysql>flush privileges;  直接输入:mysql> quit
最后用MySQL-Front又连接不上,要把 --skip-networking选项去掉