我有下面的php代码来连接到mysql。
mysql_connect( "myserver.com" , "root", "redhat","datastore") or die(mysql_error()); 当我运行这段代码时,我看到一个错误:
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但是myserver.com的IP,当我在命令提示符下执行ping myserver.com时,它给出了10.25.15.95
,所以我将代码修改为:
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. 请帮我解决这个问题..。
提前谢谢..。
发布于 2014-05-19 09:40:21
在mysql服务器上:
mysql> use mysql;
mysql> CREATE USER 'root'@'client_ipaddress' IDENTIFIED BY 'redhat';
mysql> GRANT ALL PRIVILEGES ON *.* TO 'root'@'client_ipaddress' WITH GRANT OPTION;发布于 2014-05-19 09:05:17
您正在本地运行PHP脚本,但是数据库服务器位于外部(不是在本地pc上)。
大多数数据库服务器配置为不允许外部连接(这很好)。
然后,根据本地计算机的配置,传出请求也可能被防火墙阻止,.
这就是为什么你不能连接。但你一开始就不应该这么做。
永远不要将生产数据库链接到开发脚本。
别说了!
如果您意外地写了一个错误的删除本地机器上的所有查询,然后意外地启动了它,该怎么办?哎呀..。
您正在使用xampp,这里面有一个mysql服务器,然后使用localhost作为您的主机连接到它。
在本地机器上进行测试,将所有内容迁移到myserver.com主机
https://stackoverflow.com/questions/23733626
复制相似问题