We have tried almost every solution we could find on Stackoverflow but are still getting this error.
We are using Google Cloud SQL with our Laravel project. We have deployed our project in app engine and are using cloud SQL for database connection. We followed this for deployment, but after deployment we are unable to connect with the database and getting the error:
SQLSTATE[HY000] [2002] No such file or directory.
SQLSTATE[HY000] [2002] No such file or directory (SQL: select * from
sessions
whereid
= dbzqd19nOIbfwWndCLAbNYXThlIge96OM3t9MjDu limit 1)
We can establish connection with public instance IP and in our local development it is working, but when we deploy the code on app engine we are getting this issue.
App.yaml file configuration:
runtime: php
api_version: '1.0'
env: flexible
threadsafe: true
env_variables:
APP_DEBUG: 'True'
APP_KEY: '<APP KEY HERE>'
APP_LOG: errorlog
APP_NAME: <APP NAME HERE>
beta_settings: None
CACHE_DRIVER: database
cloud_sql_instances: '<project-id-here>:<region-here>:<name here>'
DB_DATABASE: <name here>
DB_HOST: 127.0.0.1 or localhost (neither work)
DB_PASSWORD: <PASSWORD HERE> (also leaving empty doesn't work)
DB_SOCKET: /mysql/mysql.sock
DB_USERNAME: root
SESSION_DRIVER: database
STORAGE_DIR: /tmp
automatic_scaling:
min_num_instances: 2
max_num_instances: 20
cpu_utilization:
target_utilization: 0.5