怎么设置MySQL就能让别人访问本机的数据库了?

for all ips use below

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

for particular ip use below

GRANT ALL PRIVILEGES ON *.* TO 'myuser'@'youripaddres' WITH GRANT OPTION;

 

http://stackoverflow.com/questions/11112555/trying-to-connect-to-mysql-and-getting-error-is-not-allowed-to-connect-to-this

 

找到MySQL配置文件,搜索“bind-address”,找到这一行:

bind-address = 127.0.0.1 在前面加一个#,注释掉这一行,保存,重启MySQL。

再通过远程访问就可以了,telnet可以发现端口也打开了。

例配置:

1. 确保skip-networking被删除或者屏蔽,否则不支持TCP/IP 访问
2. 增加行bind-address = 65.55.55.2,替代65.55.55.2 为你的服务器地址

修改后,配置为:

[mysqld]
user = mysql
pid-file = /var/run/mysqld/mysqld.pid
socket = /var/run/mysqld/mysqld.sock
port = 3306
basedir = /usr
datadir = /var/lib/mysql
tmpdir = /tmp
language = /usr/share/mysql/English
bind-address = 65.55.55.2
# skip-networking

   

 

保存并关闭配置文件
重启mysql服务器:# /etc/init.d/mysql restart

如果上面办法没有用我们可以通用mysql命令模式进行设置:

可能是你的帐号不允许从远程登陆,只能在localhost。这个时候只要在localhost的那台电脑,登入mysql后,更改 "mysql" 数据库里的 "user" 表里的 "host" 项,从"localhost"改称"%"   

CODE:mysql -u root -p123
mysql>use mysql;
mysql>update user set host = '%' where user = 'root';
mysql>select host, user from user;
posted @ 2016-06-15 12:06  穆穆兔兔  阅读(2334)  评论(0编辑  收藏  举报