Search code examples
mysqlmacosmamp

MAMP Pro: How to connect to MySql server on Mac OS via Network?


I have a PC with Mac OS 10.6 that is running as Webserver on LAN. I use MAMP Pro for that (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:

2003 - Can't connect to MySQL server on '192.168.1.10' (10061)

I make sure uncheck "Allow local access only" on tab MySql on MAMP Pro and firewall is turn off.

I try use nmap to scan the webserver and the port 3306 is not listed in result.

Hope someone can help !

Thanks !


Solution

  • 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

    open my.cnf file which is located in

    Applications/MAMP/tmp/mysql/my.cnf

    and edit the following

    bind-address = 127.0.0.1

    to

    bind-address = 0.0.0.0

    save the file and restart mysql server by typing the following command in your terminal

    sudo /etc/init.d/mysql restart

    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

    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

    hope this helps