Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I ve been trying to connect my dedicated server mysql db from my computers localhost my code is here;

$dbhost = 'domain.com';
$dbuser = 'username';
$dbpass = 'pass';

$conn = mysql_connect($dbhost, $dbuser, $dbpass) or die('Could not connect: ' . mysql_error());

$dbname = 'dbname';
mysql_select_db($dbname);

I get that error

Could not connect: Lost connection to MySQL server at 'reading initial communication packet', system error: 61

Dedicated server is Linux centos 64 bit, php 3.2.4, mysql 5.1.54

Is there any workaround that ?

Thanks

share|improve this question

3 Answers 3

up vote 0 down vote accepted

Verify that MySQL is running and if you are able to connect by using 'telnet x.x.x.x 3306'. If you can get that far, your problem exists in MySQL's permissions. If not, check the firewall (iptables -L) as the previous person suggested, and verify that my.cnf is set up to listen to tcp (make sure there is no skip_networking line).

share|improve this answer

Check the firewall settings on your dedicated server. Maybe the port for the MySql server is blocked (usally 3306).

share|improve this answer

Check the my.cnf on your MySQL server, specially the bind-address parameter. Most of the time you need it commented to accept connections on all IP addresses of the server.

share|improve this answer
    
i tried both, didnt work. on /etc/my.cnf file. –  RULE101 Jan 17 '11 at 11:04
    
@Ahmet vardar: Did you restart MySQL ? –  Iain Jan 17 '11 at 11:08
    
yes of course i did –  RULE101 Jan 17 '11 at 11:14

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.