MAMP Pro:如何通过网络连接到 Mac OS 上的 MySql 服务器?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/9511981/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
MAMP Pro: How to connect to MySql server on Mac OS via Network?
提问by Shinichi
I have a PC with Mac OS 10.6 that is running as Webserver on LAN. I use MAMP Pro for that (Apache + MySql).
我有一台装有 Mac OS 10.6 的 PC,它在 LAN 上作为 Web 服务器运行。我为此使用 MAMP Pro(Apache + MySql)。
Today, I have problem that: From other PC on LAN, I try to connect to Mysql server on Mac and the error occurred:
今天,我遇到了一个问题:从局域网上的其他电脑,我尝试连接到 Mac 上的 Mysql 服务器,但发生了错误:
2003 - Can't connect to MySQL server on '192.168.1.10' (10061)
2003 - 无法连接到“192.168.1.10”上的 MySQL 服务器 (10061)
I make sure uncheck "Allow local access only" on tab MySql on MAMP Pro and firewall is turn off.
我确保在 MAMP Pro 上的 MySql 选项卡上取消选中“仅允许本地访问”,并且防火墙已关闭。
I try use nmap to scan the webserver and the port 3306 is not listed in result.
我尝试使用 nmap 扫描网络服务器,结果中未列出端口 3306。
Hope someone can help !
希望有人能帮忙!
Thanks !
谢谢 !
回答by Ibrahim Azhar Armar
By default MySQL is limited to connect only to localhost (127.0.0.1) because of some security reason. if you want to remote access your MySQL you need to edit a default my.cnf value
由于某些安全原因,默认情况下 MySQL 仅限于连接到 localhost (127.0.0.1)。如果你想远程访问你的 MySQL 你需要编辑一个默认的 my.cnf 值
open my.cnf file which is located in
打开位于的 my.cnf 文件
Applications/MAMP/tmp/mysql/my.cnf
应用程序/MAMP/tmp/mysql/my.cnf
and edit the following
并编辑以下内容
bind-address = 127.0.0.1
绑定地址 = 127.0.0.1
to
到
bind-address = 0.0.0.0
绑定地址 = 0.0.0.0
save the file and restart mysql server by typing the following command in your terminal
通过在终端中键入以下命令保存文件并重新启动 mysql 服务器
sudo /etc/init.d/mysql restart
须藤 /etc/init.d/mysql 重启
your MySQL server should now be able to access over the network. to verify it is listening to all interface type the following in your terminal
您的 MySQL 服务器现在应该可以通过网络访问了。要验证它正在侦听所有接口,请在终端中键入以下内容
netstat -anp | grep 3306
and if you see the following in response it means it is working
如果您看到以下响应,则表示它正在工作
tcp 0 0 0.0.0.0:3306 0.0.0.0:* LISTEN -
the above information is taken from this link : http://rclermont.blogspot.in/2008/05/configuring-mysql-for-network-access.html
以上信息取自此链接:http: //rclermont.blogspot.in/2008/05/configuring-mysql-for-network-access.html
hope this helps
希望这可以帮助
回答by Gilbert
I was following Ibrahim answer but the file is no longer in that path. I ran the following command in mac mojave
我正在关注易卜拉欣的回答,但该文件不再在该路径中。我在 mac mojave 中运行了以下命令
$ mdfind -name my.cnf
/usr/local/etc/my.cnf
$ vim /usr/local/etc/my.cnf
Then made the change
然后进行了更改
bind-address = 0.0.0.0