2017-05-06 212 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進一步的細節。