mysql无法通过ip地址链接

用BitNami搭建个站点(内含mysql数据库服务、phpmyadmin和Apache web Service), 用localhost或127.0.0.1及用户名密码连接没有问题
但是本机或远程通过ip地址连接就报错了:can't connect to mysql server on 'x.x.x.x' 10061.
当然用户已经授权,允许由局域网或互联网进行外部访问,如:

$ /installdir/mysql/bin/mysql -u root -p -e "grant all privileges on *.* to 'root'@'%' identified by 'your_root_password' with grant option";
installdir为安装目录,我的是C:BitNamiwampstack-5.4.20-0

但还是报错:can't connect to mysql server on 'x.x.x.x' 10061.
找了半天原因终于找到了:

修改安装目录:

$ /installdir/mysql/bin/mysql/

我的是C:BitNamiwampstack-5.4.20-0mysql
下my.ini文件的参数:
bind-address=127.0.0.1改成bind-address=0.0.0.0
重启mysql服务。

这样被授权的的用户(允许由局域网或互联网进行外部访问)就可以通过IP远程访问了。

注释:BitNami下的phpmyadmin也是拒绝远程访问的:For security reasons, this URL is only accesible using localhost (127.0.0.1) as the hostname

需要修改phpmyadmin下相关配置,不过我没研究。

我用XAMPP搭建的站点没出现mysql禁止IP访问的问题。

作者:
         
本文版权归作者和博客园共有,欢迎转载,若转载请在文章页面明显位置给出原文连接。
原文地址:https://www.cnblogs.com/zhangzhi19861216/p/3454267.html