2、在本机登入mysql后,更改“mysql”数据库里的“user”表里的“host”项,从”localhost”改为'%'。
 代码如下:     
mysql>
mysql>use mysql;
mysql>select host from user where user='root';     


mysql>update user set host = '%' where user ='root';
修改host值(以通配符%的内容增加主机/IP地址,当然也可以直接增加某个特定IP地址,如果执行update语句时出现ERROR 1062 (23000): Duplicate entry '%-root' for key 'PRIMARY' 错误,需要select host from user where user = 'root';
查看一下host是否已经有了%这个值,如果有了直接执行下面的flush privileges;即可)
 代码如下     

mysql>flush privileges;
mysql>select host,user from user where user='root';
mysql>quit


3.
ERROR 1044 (42000): Access denied for user ''@'localhost' to database 'mysql'


1.关闭mysql
   # service mysqld stop
2.屏蔽权限
   # mysqld_safe --skip-grant-table
   屏幕出现: Starting demo from .....
3.新开起一个终端输入
   # mysql -u root mysql
   mysql> delete from user where USER='';
   mysql> FLUSH PRIVILEGES;//记得要这句话,否则如果关闭先前的终端,又会出现原来的错误
   mysql> \q