红联Linux门户
Linux帮助

MySQL外网访问

发布时间:2015-09-15 19:15:51来源:linux网站作者:four_seas_cherries

设置MySQL允许外网访问


1.修改配置文件(windows下可以不设置此项)
sudo vim /etc/mysql/my.cnf
把bind-address参数的值改成你的内/外网IP或0.0.0.0,或者直接注释掉这行.


2.登录数据库
mysql -u root -p

输入密码
mysql> use mysql;


3.查询host
mysql> select user,host from user;


4.创建host
如果没有"%"这个host值,就执行下面这两句:
mysql> update user set host='%' where user='root';
mysql> flush privileges;


5.授权用户
任意主机以用户root和密码mypwd连接到mysql服务器
mysql> GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY '123456' WITH GRANT OPTION;
mysql> flush privileges;

IP为10.39.5.74的主机以用户root和密码123456连接到mysql服务器
mysql> GRANT ALL PRIVILEGES ON *.* TO 'root'@'10.39.5.74' IDENTIFIED BY '123456' WITH GRANT OPTION;
mysql> flush privileges;


ubuntu mysql安装外网访问:http://www.linuxdiyf.com/linux/13294.html

让外网访问内网的端口转发:http://www.linuxdiyf.com/linux/12852.html