0

I lost several hours trying to connect to cloud SQL from PHP flex env, but I found the answer.

I hope this help other people.

An exception occured in driver: SQLSTATE[HY000] [2002] No such file or directory

or

Access denied for user 'root'@'cloudsql' (using password: NO)

1 Answer 1

0

1.- enable Google Cloud SQL API: https://console.cloud.google.com/apis/

enter image description here

2.- get your cloud sql instance name

enter image description here

3.- add the beta_settings to your yaml

beta_settings:
    cloud_sql_instances: "here-your-instance-name"

4.- config your doctrine dbal unix_socket

$app->register(new Silex\Provider\DoctrineServiceProvider(), array(
    'dbs.options' => array (
        'db_conn' => array(
            'driver'    => 'pdo_mysql',
            'unix_socket' => '/cloudsql/here-your-instance-name',
            'host'      => 'localhost',
            'dbname'    => 'your-database',
            'user'      => 'your-user',
            'password'  => 'your-password',
            'charset'   => 'utf8',
            'collate'   => 'utf8_spanish2_ci'
        )
    )
));

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.