简体   繁体   English

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

[英]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. 所以未经他们的许可你不能这样做。

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);

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.

相关问题 无法使用PHP将查询连接/处理到Wamp Server上的MySQL数据库中 - Unable to connect / process query into MySQL Database on Wamp Server using PHP 从WAMP服务器连接主机上的mysql数据库 - Connect mysql database on host from wamp server 无法连接到PHP中的数据库(使用WAMP服务器) - Unable to connect to database in php (using wamp server) 数据未使用Wamp Server从php代码插入mysql数据库中 - data is not inserted in mysql database from php code using wamp server php代码未使用wamp服务器从mysql数据库中获取数据 - php code is not fetching data from mysql database using wamp server 如何使用PHP从本地Wamp服务器发送电子邮件? - How to send email from local wamp server using PHP? 无法使用WAMP作为本地服务器将Android应用程序连接到MySQL数据库 - Can't connect Android application to MySQL database using WAMP as local server 如何使用MySQL与PHP将数据库从联机服务器备份到脱机服务器 - How to get database backup from online server to offline server using PHP with MySQL 如何使用php通过本地服务器连接托管服务器数据库? - how to connect hosted server database through local server using php? 无法使用PHP 7.1从WAMP Server连接到远程SQL数据库 - Unable to connect to remote SQL database from WAMP Server using PHP 7.1
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM