1. 测试是否允许远程连接
$ telnet 192.168.1.8 3306 host 192.168.1.4 is not allowed to connect to this mysql server
2. 允许特定客户端 ip 地址连接
$ mysql -u root -p Enter password: mysql> use mysql mysql> GRANT ALL ON *.* to root@'192.168.1.4' IDENTIFIED BY 'your-root-password'; mysql> FLUSH PRIVILEGES;
注意: your-root-password 填写你的服务器 mysql 的密码
扩展:
①允许所有ip访问
GRANT ALL ON *.* to root@'%' IDENTIFIED BY 'your-root-password';
②允许管理指定数据库
GRANT ALL ON database.* to root@'%' IDENTIFIED BY 'your-root-password';
③添加数据库访问用户 GRANT ALL ON *.* to user@'%' IDENTIFIED BY 'your-root-password';
如无特殊说明,文章均为本站原创,转载请注明出处
- 转载请注明来源:mysql 添加某个ip 允许访问
- 本文永久链接地址:http://www.hongxiaowei.com/xiaowei/419.html