1

I deployed my Laravel 5.6 application using Google App Engine following these steps. The Laravel app is live at a URL but I am having trouble getting MySQL set up.

I created a 2nd generation MySQL development database, then installed the Cloud SQL Proxy client on my macbook. When I try to connect to the instance I get an error that no instance was found. What am I doing wrong?

Here are the commands I ran to get my app started

$ 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.

My instance is named laraveljwtstarter that I created through the Google Cloud Platform UI. How can I connect my Laravel app to this database?

Connor Leech
  • 18,052
  • 30
  • 105
  • 150

2 Answers2

1

Well, first of all you are not connecting to the instance with the commands that you have shared. gcloud sql instances describe laraveljwtstarter - this command simply displays configuration and metadata about a Cloud SQL instance named laraveljwtstarter. As it has already been mentioned above, please make sure that the database is created before running that command and make sure you are specifying the correct database name.

If you wish to connect to the database using the Cloud SQL Proxy, you will have to first off start it up like it says in the 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.

Normally you use the Cloud SQL Proxy because it provides secure access to your Cloud SQL Second Generation instances without having to whitelist IP addresses from which you will be connecting or having to configure SSL. You will need a Cloud SQL Proxy for your application to connect to the Cloud SQL database locally. For a deployed application there is no need for setting up a Cloud SQL Proxy.

Also, here is a short, but informative video about using Cloud SQL in App Engine.

I know that my answer is broad, but you should post a more specific question to get a specific answer.

Philipp Sh
  • 967
  • 5
  • 11
0

Nevermind, just make sure the database created through the UI has actually been created!

enter image description here

Connor Leech
  • 18,052
  • 30
  • 105
  • 150