2

I have windows 7 system and installed xampp in it.

I can access phpmyadmin using http://ipaddress:8080/phpmyadmin from remote system.

But if i try to access it from php it will give me error :

Warning: mysqli::mysqli(): (HY000/2013): Lost connection to MySQL server at 'reading initial communication packet', system error: 20

My php code is

define("HOST", "X.X.X.X");
define("PORT", "port");     // The host you want to connect to.
define("USER", "user");    // The database username. 
define("PASSWORD", "password");    // The database password. 
define("DATABASE", "DBname");    // The database name.

$mysqli =  new mysqli(HOST, USER, PASSWORD, DATABASE, PORT); 
// or without port $mysqli =  new mysqli(HOST, USER, PASSWORD, DATABASE); 

if ($mysqli->connect_errno) {
    printf("Connect failed: %s\n", $mysqli->connect_error);
    exit();
}

I have also tried firewall turning off, and also allow port 3306 to firewall, but no luck. Granted all PRIVILEGES to this user with host any (%).

I have also tried using bind_address = 0.0.0.0, commenting that line, and also bind_address = X.X.X.X (my IP).

Also tried changing socket type from "MySQL" to "TCP/IP". skip-networking line is also commented default.

I have tried to access from command prompt using:

mysql -h X.X.X.X -u root -p

This will give error:

Warning: mysqli::mysqli(): (HY000/2003): Can't connect to MySQL server on 'X.X.X.X' (110).

Using localhost in same system in connection string it works fine.

Where i am wrong i can't figure out. I have searched and tried all possible solutions. Thanks for help.

Note: rather than above, right now my conf file is same as at time of installation. Please don't mark this question as duplicate.

Edit: @Jay Blanchard, As i have referred that solution also, in that case system error : 0, in my case system error : 20. Thanks for help.

herr
  • 837
  • 1
  • 8
  • 21
  • 1
    Possible duplicate of [Lost connection to MySQL server at 'reading initial communication packet', system error: 0](http://stackoverflow.com/questions/5755819/lost-connection-to-mysql-server-at-reading-initial-communication-packet-syste) – Jay Blanchard Nov 20 '15 at 12:57
  • I am not familiar with telnet much more but, I have tried using this command "telnet x.x.x.x 3306" . But i get this message - "telnet: Unable to connect to remote host: Connection timed out" – herr Nov 20 '15 at 13:41
  • It suggests that the port is not open? Have you tried an online port scan of 3306? This will confirm that the port is open or not? – Ryan Vincent Nov 20 '15 at 14:50
  • Have checked port is open. Actually i have used temporary solution for this - curl. :) – herr Nov 21 '15 at 11:25

1 Answers1

0

My research says that error 20 on sql means it is being ran from a user that is not granted system admin rights. This limits the abilities of the sql server. The way to fix this is make sure the user the server is being ran from has admin rights. This can be done in the control panel from a windows user that has admin rights.

kayleighsdaddy
  • 670
  • 5
  • 15