简体   繁体   中英

SQLSTATE[HY000] [2002] Connection refused when deploy on GCP

For my deployment I encountered this error SQLSTATE [HY000] [2002] Connection refused (SQL: select * from insurances order by created_at desc). I tried the suggestions in this tutorial https://groups.google.com/g/google-appengine/c/3EYhmYBbsjg by giving the roles to the services. I gave to the service CLOUD SQL ADMIN and EDITOR roles. But still the same problem. I have this error:

SQLSTATE[HY000] [2002] Connection refused(SQL: select * from `insurances` order by `created_at` desc)

Here the configuration of app.yaml

runtime: php72
# env: flex
# runtime_config:
#   document_root: public
runtime_config:
  document_root: public
beta_settings:
    cloud_sql_instances: CONNECTION_NAME
env_variables:
  APP_KEY: secret
  APP_STORAGE: /tmp
  VIEW_COMPILED_PATH: /tmp
  CACHE_DRIVER: database
  SESSION_DRIVER: database
  APP_NAME: Tripguard Insurance
  DB_CONNECTION: mysql
  DB_DATABASE: database
  DB_USERNAME: root
  DB_PASSWORD: password
  DB_SOCKET: "/cloudsql/CONNECTION_NAME"

I have used these credentials with the cloud shell and my queries are returning results.

I solve my challenge by following these suggestions: https://cloud.google.com/sql/docs/mysql/connect-run .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM