Host 'localhost' is not allowed to connect to this MySQL server 解决方法


起因


   系统本来就装了Mysql5.5版本,后来又装了一个WAMP,里面又一个MySQL5.1的。切换使用多了,就产生了误操作。试了一下网上大多的方法,好像都不行。但后来找到了一个可行的方法。


方法


首先停止mysql服务:

sc stop mysql

Host 'localhost' is not allowed to connect to this MySQL server_Host 'localhost&

   然后:

mysqld --skip-grant-tables

   另开一个终端,继续

mysqlcheck --check-upgrade --all-databases --auto-repair

Host 'localhost' is not allowed to connect to this MySQL server_mysql_02

   然后再输入
mysql

   就可以进入MySQL控制台了。现在可以修改mysql.user表了。


ps


如果这样还不行的话,只有重装MySQL了。Host 'localhost' is not allowed to connect to this MySQL server_Host 'localhost&_03