我有一个脚本,我希望它运行超过 5 分钟。但我当前的托管服务不允许我修改 php.ini 中的 max_time_limit (设置为 2 分钟)...所以我认为我可以使用 XAMPP 运行脚本并将数据发送到我的数据库,但我不能连接到远程数据库。

这是连接的代码:

$servername = "217.70.186.108"; //I've also tried with the name of the webpage (metagame.gg)
$username = "the_username"; //the username is not root since I've read that root can only connect from localhost. This user has all privileges. This user was created with the permision to be connected from any server (%)
$password = "the_password";
$dbname = "the_db";

$conn = new mysqli($servername, $username, $password, $dbname);

if ($conn->connect_error) {
    die("Connection failed: " . $conn->connect_error);
}

它显示此错误:

连接失败:由于连接方在一段时间后没有正确响应而尝试连接时发生错误,或者由于连接的主机未能响应而导致建立的连接失败。

任何帮助将不胜感激


嗯,你有远程访问吗?通常,防火墙会出于充分的原因阻止它...尝试使用 telnet 实用程序:telnet 217.70.186.108 3306- 您会得到什么结果?

您需要在允许从远程位置连接的 MYSQL 服务器上创建一个帐户。出于明显的安全原因,许多托管公司不允许这样做。您必须检查您的托管公司是否允许这样做,然后询问如何操作。

如果您可以通过 SSH 访问服务器,则可以将脚本复制到服务器并从 SSH 终端中运行它。PHP CLI 很可能可以通过这种方式使用