问题描述
我试图连接到一个mysql数据库从不同的服务器到数据库托管,但我得到一个错误。
I'm trying to connect to a mysql database from a different server to the one the database is hosted on but I'm getting an error.
我猜这可能与远程权限有关。这是我可以更改还是我需要让我的托管公司这样做?
I'm guessing it might be something to do with remote permissions. Is this something I can change or do I need to get my hosting company to do this?
<?php
$con = mysql_connect("mysql4-remote.hosting.net","myadmin","password123");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
?>
无法连接到mysql4-remote.hosting上的MySQL服务器。 net'(10060)PHP警告:mysql_connect()[function.mysql-connect]:无法连接到mysql4-remote.hosting.net上的MySQL服务器(10060)D:\websites\abc123\ www\test.php on line 2
推荐答案
我会说,网络设置错误:
有关进一步的帮助,请参阅此帖子:
I would say, that your login credentials or Network settings are wrong:See this post for further help:http://wiki.answers.com/Q/What_does_MySQL_error_number_10060_mean
如果您无法从外部使用隧道,请参考以下示例:
If you don't have access from outside use tunneling, here is an example:
$connection = ssh2_connect('SERVER IP', 22);
ssh2_auth_password($connection, 'username', 'password');
$tunnel = ssh2_tunnel($connection, 'DESTINATION IP', 3307);
$db = new mysqli_connect('127.0.0.1', 'DB_USERNAME', 'DB_PASSWORD',
'dbname', 3307, $tunnel)
or die ('Fail: '.mysql_error());
这篇关于PHP - 从不同的服务器连接到mysql数据库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!