[英]how to connect online mysql database server from local wamp server using php?
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 ? 我需要从我的本地phpmyadmin数据库更新我的在线phpmyadmin数据库中的一些表,这可能吗? my local machine have internet connection , 我的本地机器有互联网连接,
To connect to remote server from your local machine you need some already granted privileges
on that server itself with your IP and an username with a prespecified password . 要从本地计算机连接到远程服务器,您需要使用您的IP和具有预先指定密码的用户名对该服务器本身授予一些privileges
。 So you can't do it without their permission. 所以未经他们的许可你不能这样做。
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);
If your database is on a Shared Server Hosting. 如果您的数据库位于Shared Server Hosting上。 Some hosting providers does not allow you to connect to your databases remotely. 某些托管服务提供商不允许您远程连接到您的数据库。
Here's a quick walkthrough
of how to do a remote connection to your database. 以下是如何远程连接数据库的快速walkthrough
。
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. 如果你可以在标准的mysql端口3306上访问远程主机,这对于这种事情是好的。如果你要从本地机器上的php连接,你可能会使用其中一个php通过相同的端口具有一个连接的远程计算机的库,以及与另一个连接的本地数据库的库。 The tool will let you verify and test the connections and test the queries interactively. 该工具将允许您验证和测试连接并以交互方式测试查询。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.