【发布时间】:2015-04-22 04:27:57
【问题描述】:
我有两个类似的域
- xyz
- abc
在 xyz 我有 admin 文件夹,我的主数据库也上传到 xyz。现在我想从 xyz 数据库表中访问一些数据。我该怎么做,请帮帮我。
【问题讨论】:
-
我怎么能允许IP地址。
我有两个类似的域
在 xyz 我有 admin 文件夹,我的主数据库也上传到 xyz。现在我想从 xyz 数据库表中访问一些数据。我该怎么做,请帮帮我。
【问题讨论】:
您可以在 abc 服务器上远程连接 xyz 数据库。如果您的数据库是 mysql,那么您可以参考下面关于如何远程连接到 MySQL 数据库的链接。
http://www.rackspace.com/knowledge_center/article/mysql-connect-to-your-database-remotely
Use the following configuration settings for connecting to your database
Host name = (use the xyz server IP address)
Database name = (xyz server database name)
Database username = (xyz database username)
Database password = (the password you entered for that database user on xyz)
MySQL Connection Port = 3306
【讨论】:
假设xyz 站点的 IP 为 127.0.0.1(我知道它的本地主机,但这只是一个示例),而站点 abc 的 IP 为 127.0.0.2。
您必须在站点 xyz 的数据库中授予 IP 127.0.0.2 可以访问该数据库的权限。
在站点 abc 上,您将需要 IP 127.0.0.1 而不是 localhost。例如
$con = mysqli_connect("127.0.0.1","user","password","db");
【讨论】: