Home > Database > Mysql Tutorial > linux下允许外部ip访问mysql数据库_MySQL

linux下允许外部ip访问mysql数据库_MySQL

WBOY
Release: 2016-06-01 13:06:06
Original
1598 people have browsed it

1.首先通过telnet检测防火墙是否已关闭。

2.设置mysql 的配置文件:

/etc/mysql/my.cnf 找到 bind-address  = 127.0.0.1 将其注释掉;//不再只允许本地访问重启mysql:/etc/init.d/mysql restart;  3.使所有用户都能使用root连接到mysql数据库:mysql -u  root -p输入密码mysql> use mysql;mysql> select host, user from user; mysql>grand all privileges on  *.*  to root@'%'  identifies  by 'xxxx' with grant option;其中第一个*表示数据库名;第二个*表示该数据库的表名; *.*的话表示所有到数据库下到所有表都允许访问。 ‘%’:表示允许访问到mysql的ip地址,%表示所有ip均可以访问。‘xxxx’为root用户的password。mysql> flush privileges; //使修改生效4.单个用户的IP(XXX.XXX.XXX.XXX)能使用root连接到mysql数据库:mysql -u  root -p输入密码mysql> use mysql;mysql> select host, user from user;mysql>grand all privileges on  *.*  to root@'XXX.XXX.XXX.XXX'  identifies  by 'xxxx' with grant option; 其中第一个*表示数据库名;第二个*表示该数据库的表名; *.*的话表示所有到数据库下到所有表都允许访问。‘%XXX.XXX.XXX.XXX’:表示允许访问到mysql的ip地址。后面到‘xxxx’为root用户的password。mysql> flush privileges; //使修改生效

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template