我尝试从PHP flex env连接到云SQL几个小时,但我找到了答案。
我希望这有助于其他人。
An exception occured in driver: SQLSTATE[HY000] [2002] No such file or directory
或
Access denied for user 'root'@'cloudsql' (using password: NO)
答案 0 :(得分:0)
1.-启用Google Cloud SQL API:https://console.cloud.google.com/apis/
2.-获取您的云sql实例名称
3.-将beta_settings添加到您的yaml
beta_settings:
cloud_sql_instances: "here-your-instance-name"
4.-配置你的学说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'
)
)
));