我在DigitalOcean有一个Droplet,在另一个托管服务提供商有一个带有域的网站空间。我无权访问其他服务器上的ftp以外的任何内容。在那个其他网站空间我有一个PHP脚本,我想远程连接到我的Droplet上的mySQL数据库。我在防火墙中打开了端口3306,添加了一个可以从%访问该表的用户,并在配置文件中更改了以“bind-adress”(也尝试注释掉)开头的行。尝试连接时,我仍然收到这样的错误:
Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[HY000]
[2002] Connection timed out' in {the url to the script that's trying to connect}:19
Stack trace: #0 {the url to the script that's trying to connect}(19): PDO->__construct('mysql:host={my droplet public ip}, '{username}', '{password}') #1 {main}
thrown in {the url to the script that's trying to connect} on line 19
php中的连接部分如下所示:
$db = new PDO('mysql:host={droplet public ip};port=3306;dbname={database name};charset=utf8', '{username}', '{password}');
我做错了什么?!
答案 0 :(得分:0)
当我联系"其他托管公司"的支持时他们告诉我,他们的服务器上不允许传入或传出对另一个数据库的请求。尽管如此,他们今天早些时候告诉我,允许传出请求。