2017-05-06 204 views
0

我有一个使用Google Application Engine部署的Laravel 5.3应用程序。然而,当我查询我的数据库,我面临着以下错误:拒绝连接 - 连接到Google Cloud SQL

SQLSTATE[HY000] [2002] Connection refused (SQL: select * from `users` where `email` = [email protected] limit 1) 

app.yaml文件内容如下:

runtime: php 
env: flex 

runtime_config: 
    document_root: public 

# required on some platforms so ".env" is not skipped 
skip_files: false 

env_variables: 
    # The values here will override those in ".env". This is useful for 
    # production-specific configuration. However, feel free to set these 
    # values in ".env" instead if you prefer. 
    APP_LOG: errorlog 
    STORAGE_DIR: /tmp 
    MYSQL_DSN: mysql:unix_socket=/cloudsql/zoho-portal-159018:us-central1:zoho-portal;dbname=zoho_portal 
    MYSQL_USER: adeel 
    MYSQL_PASSWORD: pass 

beta_settings: 
    cloud_sql_instances: zoho-portal-159018:us-central1:zoho-portal 

我已按照this教程中列出的所有步骤。我也确保我的Cloud SQL API已启用。

+0

请尝试遵循此特定[Laravel on GAE Flex指南](https://cloud.google.com/community/tutorials/run-laravel-on-appengine-flexible)。也可以尝试在app.yaml中的'cloud_sql_instances'连接名称周围使用引号''',如指南所示。 – Jordan

+0

我已按照指示进行操作,并根据说明更新了我的app.yaml文件。我访问时发生错误(https://zoho-portal-159018.appspot.com/): SQLSTATE [HY000] [2002] No such file or directory(SQL:select * from'sessions' where'id' = ySejUS01EZ5kRcZQrrFh8RcMdVybiOfVjio9vNW0限制1) 这可能与数据库的设置有关吗? –

回答

0

使用数据库会话驱动程序时,您需要设置一个表来包含会话项目。下面是表的例子架构声明:

Schema::create('sessions', function($table) 
{ 
    $table->string('id')->unique(); 
    $table->text('payload'); 
    $table->integer('last_activity'); 
}); 

您可以找到“会话” documentation page为Laravel进一步的细节。