无法使用PHP Google App Engine连接Cloud SQL

时间:2018-09-21 13:31:30

标签: google-cloud-platform cloud google-cloud-sql

我只是部署以下应用。而且我收到错误。请帮我解决这个问题。

$instance_name = "mysql:unix_socket=/cloudsql/My_Project_ID:google-cloud-instance";
$c = new mysqli(null, "root", "My_Password", 'My_DB_Name', 0, $instance_name);
if ($c->connect_error) {
    echo $c->connect_error;
    $c = null;
} else {    
    echo "Connected ";
}

我在类似的浏览器中收到错误

Unable to find the socket transport "unix" - did you forget to enable it when you configured PHP?

1 个答案:

答案 0 :(得分:0)

socket argument没有说任何有关前缀的信息:

$socket_path = "/cloudsql/My_Project_ID:google-cloud-instance";
$c = new mysqli(null, "my-user", "my-password", 'my-db', $socket_path);