Connect to remote MySQL DB

kgarner

macrumors 68000
Original poster
Jan 28, 2004
1,512
0
Utah
Okay, here is the situation. I have a PHP script that will read my iTunes Library file and store that info in a MySQL DB. It works great when I have it put it into my local MySQL DB. But I want it to store that info in the DB on my Web Server.

When I change the connection settings to my Web Server's MySQL DB I get a connection error. This happens when I run it from my local machine and try to connect to the Server's DB. I have triple checked the settings and it should be right. Is there some obvious thing I am missing?
 

belvdr

macrumors 603
Aug 15, 2005
5,660
1,001
No longer logging into MR
Are remote connections allowed to the remote MySQL database? You can see this, if you have shell access, by issuing netstat

Code:
netstat -an | grep 3306
This is assuming that MySQL is running on 3306, the default port. If it has been changed, try using lsof to find it:

Code:
lsof -i4 -P | grep mysql
Good luck.
 

kgarner

macrumors 68000
Original poster
Jan 28, 2004
1,512
0
Utah
Awesome I will try that when I get home. I was wondering if there was some feature like this, but my knowledge of backend systems is basic at best. I know enough to be dangerous, but not enough to fix what I break if you know what I mean.
 

belvdr

macrumors 603
Aug 15, 2005
5,660
1,001
No longer logging into MR
Been there, done that. I work on the backend systems at work, so I'm here if you need me.

If you do find that the MySQL database is listening on 127.0.0.1, you can check the my.cnf file, usually located in /etc. Look for the following parameter under the mysqld section. Here's my setup:

Code:
osx.us.oracle.com:~ # netstat -an | grep 3306
tcp        0      0 127.0.0.1:3306          0.0.0.0:*               LISTEN
osx.us.oracle.com:~ # more /etc/my.cnf
[client]
port            = 3306
socket          = /var/lib/mysql/mysql.sock

[mysqld]
port            = 3306
bind_address    = 127.0.0.1