0

I'm getting

Lost connection to MySQL server at 'reading initial communication packet', system error: 2

error while I'm going to connect my db.

If I'm using localhost everything is working fine. But when I'm using my live IP address like the one below, I'm getting the error:

mysql_connect("202.131.xxx.106:xxxx", "xxxx", "xxxxx") or die(mysql_error());

Please help me. Thanks.

No Idea For Name
  • 11,411
  • 10
  • 42
  • 70
user2637639
  • 47
  • 1
  • 3
  • 9

2 Answers2

0

Why not to use just localhost?

Try without port number.

or

Please check your server configuration and which port you are using.

Amit Sukapure
  • 359
  • 2
  • 11
0

You can try following things:

  1. Make sure your Live IP is open to public requests
  2. Port is working fine. Usually MySQL use 3306
  3. Another way to check port is working or not is to use it with localhost
  4. The user you are using has object(db) access
  5. Try using root user credentials (but only for testing strictly)
  6. If its connecting with root credentials then create two separate users my_user@localhost and my_user@% and grand object access
adnanyousafch
  • 1,172
  • 9
  • 26
  • if i put localhost its working fine. but i have to access from my server. Please help me. – user2637639 Jul 31 '13 at 10:49
  • It seems that you are trying to access MySQL on one server from another server. In that case you skipped the Point 1. You need to enable remote access on MySQL server so it can be accessed by other server. See http://stackoverflow.com/a/12844804/1032299 on how to enable remote access. – adnanyousafch Jul 31 '13 at 16:48