ERROR 1130: Host ’192.168.1.3′ is not allowed to connect to this MySQL server
这是告诉你没有权限连接指定IP的主机,下面我们来看看解决办法。
在生产环境中,mysql通常会部署在某个独立的数据服务器上,所以需要向后端的应用服务器定向开放。
一般报错:
格式:
GRANT ALL PRIVILEGES ON 数据库名.表名 TO '用户名'@'ip地址' IDENTIFIED BY '密码' WITH GRANT OPTION;
flush privileges;
示例:
GRANT ALL PRIVILEGES ON *.* TO 'root'@'127.12.50.60' IDENTIFIED BY 'password2' WITH GRANT OPTION;
flush privileges;
全ip全表开放
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'password2' WITH GRANT OPTION;
flush privileges;
方法2:
GRANT SELECT,INSERT,UPDATE,DELETE ON [db_name].* TO [username]@[ipadd] identified by '[password]';
方法3:
update user set host = '%' where user = 'root';
select host, user from user;