首页 > 解决方案 > 如何从 GoDaddy 服务器连接到 Google Cloud SQL 数据库

问题描述

我正在尝试从托管在 godaddy 服务器上的网站连接到谷歌云上的 sql 实例。

我收到以下错误

Failed to connect to MySQL: Can't connect to MySQL server on 'xxx.xxx.xxx.xxx' (110)

我已将 IP 授权给我的 Godaddy 服务器。

这是我处理连接的方式...

<?php

    // Change this to your connection info.
    $DATABASE_HOST = 'xxx.xxx.xxx.xxx';
    $DATABASE_USER = 'user';
    $DATABASE_PASS = 'pass';
    $DATABASE_NAME = 'db';
    // Try and connect using the info above.
    $con = mysqli_connect($DATABASE_HOST, $DATABASE_USER, $DATABASE_PASS, $DATABASE_NAME);
    if ( mysqli_connect_errno() ) {
        // If there is an error with the connection, stop the script and display the error.
        die ('Failed to connect to MySQL: ' . mysqli_connect_error());
    }

?>

我已经被卡住了一段时间,没有在网上看到任何可以提供帮助的东西。

标签: phpmysqligoogle-cloud-platform

解决方案


推荐阅读