php 如何使用php从本地wamp服务器连接在线mysql数据库服务器?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/19749680/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-25 19:57:46  来源:igfitidea点击:

how to connect online mysql database server from local wamp server using php?

phpmysql

提问by Mujeeb Iqbal

I need to connect my online mysql database from local wamp/xampp server using php

我需要使用 php 从本地 wamp/xampp 服务器连接我的在线 mysql 数据库

I need to update some table in my online phpmyadmin database from my local phpmyadmin database , It is possible ? my local machine have internet connection ,

我需要从我的本地 phpmyadmin 数据库更新我的在线 phpmyadmin 数据库中的一些表,这可能吗?我的本地机器有互联网连接,

回答by Rajesh Paul

To connect to remote server from your local machine you need some already granted privilegeson that server itself with your IPand an usernamewith a prespecified password. So you can't do it without their permission.

要从您的本地机器连接到远程服务器,您需要privileges在该服务器上已经授予一些您的IP和一个带有预先指定密码用户名。所以没有他们的许可,你不能这样做。

Check this answer

检查这个答案

After that you are allowed to create connection to that remote database server using the following syntax:

之后,您可以使用以下语法创建与该远程数据库服务器的连接:

$hostname='www.facebook.com';// Remote database server Domain name.
$username='username';// as specified in the GRANT command at that server.
$password='password';// as specified in the GRANT command at that server.
$dbname='testdb';// Database name at the database server.
$mysqli = new mysqli($hostname, $username, $password, $dbname);

回答by Shankar Damodaran

If your database is on a Shared Server Hosting. Some hosting providers does not allow you to connect to your databases remotely.

如果您的数据库位于共享服务器托管上。某些托管服务提供商不允许您远程连接到您的数据库。

Here's a quick walkthroughof how to do a remote connection to your database.

以下walkthrough是如何对数据库进行远程连接的快速说明。

回答by dkretz

Try downloading SQLYog (Community edition).

尝试下载 SQLYog(社区版)。

http://code.google.com/p/sqlyog/downloads/list

http://code.google.com/p/sqlyog/downloads/list

It's good for this sort of thing, if you can get to the remote host on standard mysql port 3306. If you're going to connect from php on your local machine, you'll probably go through the same port using one of the php libraries to the remote machine with one connection, and to your local database with with another connection. The tool will let you verify and test the connections and test the queries interactively.

如果您可以通过标准 mysql 端口 3306 访问远程主机,这对此类事情很有用。如果您要从本地计算机上的 php 连接,您可能会使用其中一个 php库通过一个连接传输到远程机器,通过另一个连接传输到本地数据库。该工具将让您验证和测试连接并以交互方式测试查询。