I have some existing code in php for server side coding and the db is MySql. Both resides on the production(realtime) database.
我在php中有一些用于服务器端编码的现有代码,db是MySql。两者都驻留在生产(实时)数据库中。
Some job is given to me to fetch the records from the actual server and display in some format on local machine. I cannot duplicate the data onto my local system due to security reason. Any ideas how can i connect to production server and get my query run. I am ready to recreate the server side coding also....any help is appreciated....
我有一些工作是从实际服务器获取记录并在本地计算机上以某种格式显示。由于安全原因,我无法将数据复制到本地系统。任何想法如何连接到生产服务器并运行我的查询。我准备重新创建服务器端编码....任何帮助表示赞赏....
1 个解决方案
#1
0
You will need to grant access to the production machine from your local machine. You can do so by granting all privileges on your IP address. For example, if your username was remote
and your public IP address was 10.1.0.8
, you would use this:
您需要从本地计算机授予对生产计算机的访问权限。您可以通过授予IP地址的所有权限来实现此目的。例如,如果您的用户名是远程的,并且您的公共IP地址是10.1.0.8,那么您将使用:
GRANT ALL PRIVILEGES ON *.* TO remote@'10.1.0.8';
FLUSH PRIVILEGES;
Remember to flush your updated privileges!
请记住刷新您的更新权限!
You can now connect to the production machine using PHP. For example, if your production machine was at production.example.com
, you would use this:
您现在可以使用PHP连接到生产计算机。例如,如果您的生产计算机位于production.example.com,则可以使用以下命令:
mysql_connect("production.example.com", "remote", "My-p@ssw0rd");
mysql_select_db("example_db");
If you don't have root access to the production machine or can't grant privileges for some reason, you can also try to set up an SSH tunnel, if you have access to SSH.
如果您没有对生产计算机的root访问权限或由于某种原因无法授予权限,则还可以尝试设置SSH隧道(如果您可以访问SSH)。
Instructions on how to set up an SSH tunnel can be found here (Windows/PuTTY).
可以在此处找到有关如何设置SSH隧道的说明(Windows / PuTTY)。
You can then connect to whatever you used as local port using PHP as PuTTY will route all traffic through its SSH tunnel to the remote production server, making the production server to believe you connected from localhost
:
然后,您可以使用PHP连接到您用作本地端口的任何内容,因为PuTTY会将所有流量通过其SSH隧道路由到远程生产服务器,使生产服务器相信您从localhost连接:
mysql_connect("localhost", "remote", "My-p@ssw0rd");
mysql_select_db("example_db");
#1
0
You will need to grant access to the production machine from your local machine. You can do so by granting all privileges on your IP address. For example, if your username was remote
and your public IP address was 10.1.0.8
, you would use this:
您需要从本地计算机授予对生产计算机的访问权限。您可以通过授予IP地址的所有权限来实现此目的。例如,如果您的用户名是远程的,并且您的公共IP地址是10.1.0.8,那么您将使用:
GRANT ALL PRIVILEGES ON *.* TO remote@'10.1.0.8';
FLUSH PRIVILEGES;
Remember to flush your updated privileges!
请记住刷新您的更新权限!
You can now connect to the production machine using PHP. For example, if your production machine was at production.example.com
, you would use this:
您现在可以使用PHP连接到生产计算机。例如,如果您的生产计算机位于production.example.com,则可以使用以下命令:
mysql_connect("production.example.com", "remote", "My-p@ssw0rd");
mysql_select_db("example_db");
If you don't have root access to the production machine or can't grant privileges for some reason, you can also try to set up an SSH tunnel, if you have access to SSH.
如果您没有对生产计算机的root访问权限或由于某种原因无法授予权限,则还可以尝试设置SSH隧道(如果您可以访问SSH)。
Instructions on how to set up an SSH tunnel can be found here (Windows/PuTTY).
可以在此处找到有关如何设置SSH隧道的说明(Windows / PuTTY)。
You can then connect to whatever you used as local port using PHP as PuTTY will route all traffic through its SSH tunnel to the remote production server, making the production server to believe you connected from localhost
:
然后,您可以使用PHP连接到您用作本地端口的任何内容,因为PuTTY会将所有流量通过其SSH隧道路由到远程生产服务器,使生产服务器相信您从localhost连接:
mysql_connect("localhost", "remote", "My-p@ssw0rd");
mysql_select_db("example_db");