Home >Database >Mysql Tutorial >解决MySQL无法远程访问的方法_MySQL

解决MySQL无法远程访问的方法_MySQL

WBOY
WBOYOriginal
2016-06-01 13:44:15794browse

bitsCN.com

 

关闭/开启Red hat防火墙

 

/* 关闭防火墙*/

 

service iptables stop

 

/* 开启防火墙*/

 

service iptables start

 

/* 默认关闭防火墙*/

 

chkconfig iptables off

 

授权法。

例如,你想myuser使用mypassword从任何主机连接到mysql服务器的话。

GRANT ALL PRIVILEGES ON *.* TO 'myuser'@'%' IDENTIFIED BY 'mypassword' WITH GRANT OPTION;

FLUSH   PRIVILEGES;

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

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

FLUSH   PRIVILEGES;

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

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

FLUSH   PRIVILEGES;

我用的第一个方法,刚开始发现不行,在网上查了一下,少执行一个语句mysql>FLUSH RIVILEGES 使修改生效.就可以了

 

作者 iloveyin

bitsCN.com
Statement:
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