用PHP连接外部MySQL数据库 [英] connecting external mysql database with php
问题描述
是否可以在服务器之间连接mysql数据库.我的意思是,可以说我在2个不同的托管服务上有2个帐户,其中一个有数据库,我想用php从另一个帐户连接它.
Is that possible to connect mysql database between servers. I mean, lets say i have 2 accounts on 2 different hosting service, one of them has database, and i want to connect it from other one with php.
尝试时,出现警告:mysql_connect()[function.mysql-connect]:在查询过程中与MySQL服务器的连接已断开..."
When i try it, i get "Warning: mysql_connect() [function.mysql-connect]: Lost connection to MySQL server during query..."
我的数据库位于godaddy上,我将其设置为启用外部访问.
my database is located on godaddy and i set it external access enabled.
我看到有可能,但是我的主机只允许通过软件进行连接;
I see it is possible but my host only allows connection via software;
要使用直接数据库访问功能远程连接到共享的托管数据库,您需要下载可连接到数据库并对其进行管理的软件."
"To use Direct Database Access to connect remotely to your shared hosting database, you need to download software that lets you connect to the database and manage it."
推荐答案
这很有可能.
确保拥有数据库的主机允许外部连接,并允许该用户名/密码组合访问数据库(通常是通过mySQL的GRANT选项进行设置)
Make sure the host that has your database allows for external connections and allows that username/password combination to access the database (Usually something set via mySQL's GRANT option)
这篇关于用PHP连接外部MySQL数据库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!