【问题标题】:Connect silex 2 dbal connect app engine with cloud sql使用云 sql 连接 silex 2 dbal 连接应用程序引擎
【发布时间】:2018-04-09 16:31:54
【问题描述】:

我在尝试从 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)

【问题讨论】:

    标签: symfony google-app-engine google-cloud-sql silex dbal


    【解决方案1】:

    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'
            )
        )
    ));
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-08-22
      • 1970-01-01
      • 2020-07-29
      • 1970-01-01
      • 2020-05-18
      • 1970-01-01
      相关资源
      最近更新 更多