如何连接到另一个域上的MySQL数据库? [英] How to connect to a MySQL database on another domain?
问题描述
基本上,我需要连接到另一个域上的另一个数据库.
Basically, I need to connect to another database on a different domain.
例如,我将使用domain1
和需要连接的域,并使用domain2
作为具有数据库的域.
For example, I'll use domain1
and the domain that needs to connect, and domain2
as the domain that has the database.
我尝试过:
mysql_connect("domain2.com.au", "user", "pass") or die(mysql_error());
mysql_select_db("database") or die(mysql_error());
尽管,那拒绝了.
我花了很长时间在网上寻找解决方案,其中许多涉及登录我不熟悉的SSH
,我想避免这种方法.
I looked for quite some time online to find a solution, and many of them involved logging into SSH
which I am not familiar with and I would like to avoid this method.
如果需要,这是我的错误(为保护隐私而对某些内容进行了修改):
If needed, here is my error (some things modified for privacy):
Warning: mysql_connect() [function.mysql-connect]: Access denied for user 'user'@'host.com' (using password: YES) in /php/2012.php on line 270
Access denied for user 'user'@'host.com' (using password: YES)
我是否必须更改数据库中的选项以允许来自其他域的访问?如果是这样,这到底在哪里?
Is there an option that I must change within my database to allow access from other domains? If so, where exactly is this?
我是否需要连接一个端口,例如domain2.com.au:3307
?
Is there a port that I need to connect to such as domain2.com.au:3307
?
推荐答案
如果使用共享主机,则将其禁用.您可以尝试与支持部门联系来启用它,或者如果您拥有cPanel x3,请转至MySQL部分的远程数据库"部分.
If you are using shared hosting, then it's disabled. You could try enabling it by contacting your support department, or if you have cPanel x3 go to Remote Database section in your MySQL section.
这篇关于如何连接到另一个域上的MySQL数据库?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!