Lost connection to MySQL server at 'reading initial communication packet'

StealthParanoia

Registered
Mar 5, 2013
2
0
1
cPanel Access Level
Root Administrator
I have created some PHP webpages for my friend using my localhost/ and gave them to him to upload his server.

After guessing the server that we had to connect to, we ran into some problems. Now, he is too shy to post on here and I'm bored of waiting for him to contact somebody so I'm doing it myself.

I have written the code as mysql_connect("liberty.xssl.net:2083", "usernamex", "passwordx") or die(mysql_error());
mysql_select_db("databasex") or die(mysql_error());

But this returns the error "Lost connection to MySQL server at 'reading initial communication packet', system error: 0".

Have I put the wrong host name in where it says "liberty.xssl.net:2083"? If so, what should I have put in?

Thanks,

~Finchyy

P.S. Where it says "usernamex", "passwordx" and "databasex" is where his actual username, password and database name is.
 

quietFinn

Well-Known Member
Feb 4, 2006
1,844
429
438
Finland
cPanel Access Level
Root Administrator
Would that work on a server..? I know that that would work on your local machine but...
If the PHP application and mySQL are running in the same server then you can use "localhost".
 

cPanelMichael

Administrator
Staff member
Apr 11, 2011
47,880
2,258
463
hi I have the same problem i tried replacing the hostname to localhost but it gave me this error Access denied for user '[email protected]'@'localhost' (using password: YES). How can i solve this one? thanks
It looks like you may not be using a valid format for your MySQL username. Check to make sure you enter the database username exactly as it appears in cPanel.

Thank you.