SQLSTATE [HY000] [2002]在GCP上部署时连接被拒绝

时间:2020-08-30 22:47:53

标签: mysql database laravel google-cloud-platform google-cloud-sql

对于我的部署,我遇到此错误SQLSTATE [HY000] [2002]连接被拒绝(SQL:从insurances中选择* 按created_at desc排序)。 我尝试了本教程中的建议 https://groups.google.com/g/google-appengine/c/3EYhmYBbsjg,将角色赋予服务。我为服务提供了CLOUD SQL ADMIN和EDITOR角色。但是仍然是同样的问题。 我有这个错误:

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

这里 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"

我已将这些凭据与云外壳一起使用,我的查询正在返回结果。

1 个答案:

答案 0 :(得分:0)

我遵循以下建议来解决挑战: https://cloud.google.com/sql/docs/mysql/connect-run

相关问题