[英]Error when connecting to external db - mysqli_connect(): (HY000/2002): Connection timed out
I moved my database to an external server because the one my webhosting provider offered is just too limited (no remote access).我将我的数据库移至外部服务器,因为我的虚拟主机提供商提供的服务器太有限(无法远程访问)。 So I set a MariaDB up on a Vultr server (CentOS 7).
所以我在 Vultr 服务器(CentOS 7)上设置了 MariaDB。 everything works fine in phpmyadmin and I already imported the other db.
phpmyadmin 一切正常,我已经导入了另一个数据库。 When trying to connect from my website I get this warning tho:
尝试从我的网站连接时,我收到以下警告:
Warning: mysqli_connect(): (HY000/2002): Connection timed out in blabla/assets/php/config.php on line 8 ERROR: Could not connect. Connection timed out
PHP code PHP代码
define('DB_SERVER', '11.22.33.44');
define('DB_USERNAME', 'user');
define('DB_PASSWORD', 'pw');
define('DB_NAME', 'data');
$link = mysqli_connect(DB_SERVER, DB_USERNAME, DB_PASSWORD, DB_NAME);
if($link === false){
die("ERROR: Could not connect. " . mysqli_connect_error());
}
It worked perfectly fine with the old db so I assume Im missing someting but I can't figure it out.它与旧数据库完美配合,所以我认为我错过了一些东西,但我无法弄清楚。 I tried opening the 3306 port, tried different users, allowing all IPs but nothing works.
我尝试打开3306端口,尝试不同的用户,允许所有IP但没有任何效果。
Thanks for everyone who tried to help but sadly the problem is not on my end.感谢所有试图提供帮助的人,但遗憾的是问题不在我这边。 Turned out that one.com also does not allow outgoing connections to other databases than their own.
原来,一个.com 也不允许与自己以外的其他数据库的传出连接。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.