【问题标题】:How to connect two websites from single database which uploads in different domains如何从在不同域上传的单个数据库连接两个网站
【发布时间】:2015-04-22 04:27:57
【问题描述】:

我有两个类似的域

  1. xyz
  2. abc

在 xyz 我有 admin 文件夹,我的主数据库也上传到 xyz。现在我想从 xyz 数据库表中访问一些数据。我该怎么做,请帮帮我。

【问题讨论】:

  • 我怎么能允许IP地址。

标签: php mysql


【解决方案1】:

您可以在 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

【讨论】:

    【解决方案2】:

    假设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");
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2023-02-11
      • 2016-01-18
      • 1970-01-01
      • 2018-11-04
      • 2016-04-23
      • 1970-01-01
      • 2012-04-04
      • 1970-01-01
      相关资源
      最近更新 更多