php MySql connectivity error

PaDi picture PaDi · May 19, 2014 · Viewed 8.1k times · Source

I have the following php code to connect to my mysql DB.

mysql_connect( "myserver.com" , "root", "redhat","datastore") or die(mysql_error()); 

when I ran this code I got the error saying:

Warning: mysql_connect(): Host '10.21.21.10' is not allowed to connect to this MySQL server in C:\xampp\htdocs\inventory\net.php on line 20
Host '10.21.21.10' is not allowed to connect to this MySQL server

But the IP of myserver.com when I did ping myserver.com in command prompt it gave 10.25.15.95

,so I Modified the code to:

mysql_connect( "10.21.21.10" , "root", "redhat","datastore") or die(mysql_error()); 

the same error repeated.

Then i changed my code to:

mysql_connect( "10.25.15.95" , "root", "redhat","datastore") or die(mysql_error()); 

the error was

Warning: mysql_connect(): A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond. in C:\xampp\htdocs\inventory\net.php on line 20
A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond. 

Please help me in solving this..

Thanks in advance...

Answer

fortune picture fortune · May 19, 2014

At your mysql server:

mysql> use mysql;   

mysql> CREATE USER 'root'@'client_ipaddress' IDENTIFIED BY 'redhat';

mysql> GRANT ALL PRIVILEGES ON *.* TO 'root'@'client_ipaddress' WITH GRANT OPTION;