Laravel MySQL Google App Engine - ERROR: (gcloud.sql.instances.describe) There was no instance found

Laravel MySQL Google App Engine - ERROR: (gcloud.sql.instances.describe) There was no instance found

我在 these steps 之后使用 Google App Engine 部署了我的 Laravel 5.6 应用程序。 Laravel 应用程序在 URL 上线,但我无法设置 MySQL。

我创建了第二代 MySQL 开发数据库,​​然后 installed the Cloud SQL Proxy client 在我的 macbook 上。当我尝试连接到该实例时,我收到一条错误消息,指出未找到任何实例。我做错了什么?

这是我 运行 启动我的应用程序的命令

$ gcloud init 
$ gcloud app deploy
$ gcloud app browse
$ curl -o cloud_sql_proxy https://dl.google.com/cloudsql/cloud_sql_proxy.darwin.amd64
$ chmod +x cloud_sql_proxy
$ gcloud sql instances describe laraveljwtstarter
ERROR: (gcloud.sql.instances.describe) There was no instance found at
projects/laraveljwtstarter/instances/laraveljwtstarter or you are not 
authorized to access it.

我的实例名为 laraveljwtstarter,是我通过 Google 云平台 UI 创建的。如何将我的 Laravel 应用程序连接到此数据库?

没关系,只要确保通过UI创建的数据库确实已创建即可!

嗯,首先,您没有使用共享的命令连接到实例。 gcloud sql instances describe laraveljwtstarter - 此命令仅显示有关名为 laraveljwtstarter 的 Cloud SQL 实例的配置和元数据。正如上面已经提到的,请确保在 运行 该命令之前创建了数据库,并确保您指定了正确的数据库名称。

如果您希望使用云 SQL 代理连接到数据库,您必须首先按照 article you mentioned. As far as I understood, you have an application in App Engine, therefore you are using the wrong example from the documentation. Generally, if you want to connect your GAE app with the Cloud SQL instance, there is a number of options, depending if you are using App Engine Standard environment or Flexible environment. Both options are available for PHP and you can read more here 中的说明启动它。

通常您使用云 SQL 代理,因为它提供对您的云 SQL 第二代实例的安全访问,而无需将您将要连接的 IP 地址列入白名单或必须配置 SSL。您将需要一个云 SQL 代理,以便您的应用程序在本地连接到云 SQL 数据库。对于已部署的应用程序,无需设置云 SQL 代理。

此外,here 是一个关于在 App Engine 中使用 Cloud SQL 的简短但内容丰富的视频。

我知道我的回答很笼统,但您应该 post 一个更具体的问题以获得具体的答案。