先谢谢您
我正在尝试将laravel项目部署到Google云(使用APP ENGINE) 但是,我几乎做了些事情,但是无法连接到数据库
当我使用php artisan migrate
迁移表时,它显示在错误下方
SQLSTATE[HY000] [2002] No such file or directory (SQL: select * from information_schema.tables where table_schema = demo-db and table_name = migrations and table_type = 'BASE TABLE
我的app.yaml
如下所示
runtime: php
env: flex
runtime_config:
document_root: public
skip_files:
- .env
env_variables:
APP_NAME: Demo
APP_ENV: local
APP_KEY: base64:991ihCoj56qE2RiLqaf+LnBdOBfPzaER2cd4d5d4d4
APP_DEBUG : true
APP_URL: https://demo.ue.r.appspot.com
CACHE_DRIVER: file
SESSION_DRIVER: file
SESSION_LIFETIME: 120
APP_LOG: daily
APP_TIMEZONE: UTC
DB_CONNECTION: mysql
DB_HOST: DB_HOST
DB_DATABASE: DB_DATABASE
DB_USERNAME: DB_DATABASE
DB_PASSWORD: DB_PASSWORD
DB_SOCKET: "DB_SOCKET"
QUEUE_DRIVER: database
MAIL_DRIVER: smtp
MAIL_HOST: smtp.googlemail.com
MAIL_PORT: 465
MAIL_USERNAME: MAIL_USERNAME
MAIL_PASSWORD: MAIL_USERNAME
LOG_DELETE: true
GOOGLE_VISION_PROJECT_ID : GOOGLE_VISION_PROJECT_ID
beta_settings:
cloud_sql_instances: demo-db
我还遵循了https://medium.com/hackernoon/how-to-deploy-a-laravel-web-app-on-google-app-engine-ecfbb0d49b00
的步骤答案 0 :(得分:1)
替换此部分:
DB_SOCKET: "DB_SOCKET"
beta_settings:
cloud_sql_instances: demo-db
具有以下内容:
DB_SOCKET: /cloudsql/YOUR_CLOUDSQL_CONNECTION_NAME
beta_settings:
cloud_sql_instances: YOUR_CLOUDSQL_CONNECTION_NAME
其中YOUR_CLOUDSQL_CONNECTION_NAME
的格式为 projectname:region:instancename
您可以通过导航到Cloud Console> SQL>实例连接名称来获取此信息
社区教程:Laravel PHP-App Engine Flex-Cloud SQL:
类似的问题:
答案 1 :(得分:1)
DB_DATABASE: DB_DATABASE
DB_USERNAME: DB_DATABASE
DB_PASSWORD: DB_PASSWORD
仅添加上述声明,并删除其余内容即可在.env