Friday, October 19, 2018

[google-cloud-sql-discuss] SQLSTATE[HY000] [2002] No such file or directory, google cloud app engine flexible

I am trying to connect cloud sql socket with google cloud app engine flexible.


My code is as bellow:


$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

Getting bellow error

SQLSTATE[HY000] [2002] No such file or directory


--
You received this message because you are subscribed to the Google Groups "Google Cloud SQL discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-cloud-sql-discuss+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-cloud-sql-discuss/110133e6-de24-4ede-88d5-ee25e8990be6%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment