php MySql连接错误 [英] php MySql connectivity error
问题描述
我有以下php代码可连接到我的mysql数据库.
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
但是当我在命令提示符下 ping myserver.com 时,myserver.com的IP给出了10.25.15.95
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());
重复同样的错误.
然后我将代码更改为:
mysql_connect( "10.25.15.95" , "root", "redhat","datastore") or die(mysql_error());
错误是
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..
预先感谢...
推荐答案
在您的mysql服务器上:
At your mysql server:
mysql>使用mysql;
mysql> use mysql;
mysql>创建用户'root'@'client_ipaddress'由'redhat'标识;
mysql> CREATE USER 'root'@'client_ipaddress' IDENTIFIED BY 'redhat';
mysql>将上的所有特权授予.带有GRANT OPTION的'root'@'client_ipaddress';
mysql> GRANT ALL PRIVILEGES ON . TO 'root'@'client_ipaddress' WITH GRANT OPTION;
这篇关于php MySql连接错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!