首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >php MySql连接性错误

php MySql连接性错误
EN

Stack Overflow用户
提问于 2014-05-19 08:58:43
回答 2查看 8.5K关注 0票数 2

我有下面的php代码来连接到mysql。

代码语言:javascript
运行
复制
mysql_connect( "myserver.com" , "root", "redhat","datastore") or die(mysql_error()); 

当我运行这段代码时,我看到一个错误:

代码语言:javascript
运行
复制
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

,所以我将代码修改为:

代码语言:javascript
运行
复制
mysql_connect( "10.21.21.10" , "root", "redhat","datastore") or die(mysql_error()); 

同样的错误重复出现。

然后,我将代码更改为:

代码语言:javascript
运行
复制
mysql_connect( "10.25.15.95" , "root", "redhat","datastore") or die(mysql_error()); 

错误是

代码语言:javascript
运行
复制
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. 

请帮我解决这个问题..。

提前谢谢..。

EN

Stack Overflow用户

回答已采纳

发布于 2014-05-19 09:40:21

在mysql服务器上:

代码语言:javascript
运行
复制
mysql> use mysql;   

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

mysql> GRANT ALL PRIVILEGES ON *.* TO 'root'@'client_ipaddress' WITH GRANT OPTION;
票数 2
EN
查看全部 2 条回答
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/23733626

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档