您的位置:首页 > 数据库 > MySQL

ERROR 1130: Host '' is not allowed to connect to this MySQL server

2016-04-22 11:08 615 查看
原因:安装mysql的时候没有赋予root高级权限。

1、改表法

登入mysql后,进入"mysql" 数据库

use mysql
update user set host= '%' where user = 'root'; --此时如果提示报错,不用管,继续往下走
select host, user from user;
flush privileges;  -- * 这一句是刷新刚才的内容  *一定要刷新,因为操作的是系统授权表。。


2、授权法

例如,你想myuser使用mypassword从任何主机连接到mysql服务器的话。GRANT ALL PRIVILEGES ON *.* TO 'myuser'@'%' IDENTIFIED BY 'mypassword' WITH GRANT OPTION;

如果你想允许用户myuser从ip为192.168.1.3的主机连接到mysql服务器,并使用mypassword作为密码

GRANT ALL PRIVILEGES ON *.* TO 'root'@'192.168.1.3' IDENTIFIED BY 'mypassword' WITH GRANT OPTION;

GRANT ALL PRIVILEGES ON *.* TO 'root'@'10.10.40.54' IDENTIFIED BY '123456' WITH GRANT OPTION;

3、以上两个方法还不能解决时,打开Mysql(版本:Mysql server 5.5)的MySQLInstanceConfig.exe(在bin文件目录下)

Reconfigure Instance->Detailed Configuration->Server Machine->Multifunctional Database->Decision Support->(把Enable Strict Mode去掉)->Manual Selected Default Character set(utf-8)->include bin directory in windows path(在cmd环境下可以使用)->enable
root access from remote machines(设置完其他主机可访问次数据库)
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  mysql