Tente adicionar isso em app.yaml
# Use the connection name obtained when configuring your Cloud SQL instance.
beta_settings:
cloud_sql_instances: "CONNECTION_NAME"
Estou tentando conectar o cloud sql com o mecanismo de aplicativo do Google Cloud flexível.
Meu código é o seguinte:
$dsn = getenv('MYSQL_DSN');
$user = getenv('MYSQL_USER');
$password = getenv('MYSQL_PASSWORD');
try {
$db = new PDO($dsn, $user, $password);
$statement = $db->prepare("SELECT * from user");
$statement->execute();
$users = $statement->fetchAll();
} catch (Exception $e) {
echo 'Caught exception: ', $e->getMessage(), "\n";
}
app.yaml
runtime: php
env: flex
runtime_config:
document_root: .
env_variables:
MYSQL_DSN: mysql:dbname=DATABASE;unix_socket=/cloudsql/CONNECTION_NAME
MYSQL_USER: username
MYSQL_PASSWORD: password
Abaixo do erro
SQLSTATE[HY000] [2002] No such file or directory
Tente adicionar isso em app.yaml
# Use the connection name obtained when configuring your Cloud SQL instance.
beta_settings:
cloud_sql_instances: "CONNECTION_NAME"