代码之家  ›  专栏  ›  技术社区  ›  emma

PHP在一台服务器上执行PHP脚本,脚本位于第二台服务器上,并在第三台服务器上的db中插入数据[关闭]

php
  •  -1
  • emma  · 技术社区  · 7 年前

    query 服务器1中的数据库使用 php 在服务器2上编写脚本,然后在服务器3上插入该数据:

    Server-1: db - that has the data
    Server-2: get data from Server-1 db and insert it into Server-3 db
    Server-3: db - that will have the data
    

    我可以说我无法连接到 mysql 从服务器1到服务器2。

    感谢您抽出时间阅读并回答我的问题!:天

    1 回复  |  直到 7 年前
        1
  •  2
  •   Ray A    7 年前

    很简单,

    在服务器1上编写一个脚本,它将获取数据,然后从服务器2调用它。 在服务器3上,编写一个将数据插入其数据库的脚本,并从服务器2调用它。

    假设服务器名是Server1、Server2和Server3

    • 编写一个名为get users.PHP的PHP文件,它将获取所有用户 从服务器1db返回JSON。
    • http:\\Server1\getUsers.php ,它将返回您拥有的所有用户 JSON格式。
    • 现在在服务器3上,您需要编写PHP文件来存储这些 用户到它的数据库,命名为saveUsers.php
    • 服务器1到服务器3,必须使用PHP CURL将它们提交到 链接 http:\\server3\saveUsers.php

    一旦所有这些步骤都完成了,现在就有了自己的API,

    这样你就能实现你想要的。

    推荐文章