1

Having troubles with this and I'm not sure why.. I'm trying to access a mysql database from another server.

I changed the my.cnf file (uncommented the bind-address to access from all):

port=3306
#bind-address=12.34.56.78
local-infile=0
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
user=mysql
# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0
# skip-networking

I set up the user, and the user works: (I know "ALL" is bad, but I'm just trying to get this to work...)

GRANT ALL PRIVILEGES ON 'MY_DATABASE'.* TO 'MY_USERNAME'@'12.34.56.78' IDENTIFIED BY 'MY_PASSWORD'; 

I restarted mysql: /etc/init.d/mysqld restart

I opened up the port from within plesk, and then restarted the whole server. (It's a VPS)

now, when I try and telnet from my desktop, it connects, shows a bunch of garbage text then closes the connection 5 seconds later.

I'm trying to connect with php:

<?php

mysql_connect("DOMAIN.COM:3306", "MY_USERNAME", "MY_PASSWORD") or die(mysql_error());
echo "Connected to MySQL<br />";

?>

and I get a "Can't connect to MySQL server" error after a 10 second timeout.

The log files are empty, only showing when I restarted mysqld.

Any ideas or tips on how to troubleshoot this?

migrated from stackoverflow.com Feb 14 '13 at 10:51

This question came from our site for professional and enthusiast programmers.

  • Can you connect by means other than PHP using the same user/pass? – Explosion Pills Feb 14 '13 at 4:46
  • I tried putty using the telnet feature and it just opens and closes – David Feb 14 '13 at 4:47
  • Then it sounds like the problem is your mysql server is misconfigured – Explosion Pills Feb 14 '13 at 4:52
  • I think this link cyberciti.biz/tips/… can help you – Rohit Kumar Choudhary Feb 14 '13 at 5:04
  • Thanks. I followed everything on that page to a T, but still times out, and telnet shows that garbage text then closes the connection – David Feb 14 '13 at 5:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy