Using Cloud SQL database with Laravel

2,270 views
Skip to first unread message

Adeel Ahmad

unread,
Apr 28, 2017, 9:13:59 AM4/28/17
to Google App Engine
I have set up my Laravel 5.3 project on GAE using gcloud. My app.yaml file looks like this:

runtime: php
env
: flex

runtime_config
:
  document_root
: public

# required on some platforms so ".env" is not skipped
skip_files
: false

env_variables
:
 
# The values here will override those in ".env". This is useful for
 
# production-specific configuration. However, feel free to set these
 
# values in ".env" instead if you prefer.
  APP_LOG
: errorlog
  STORAGE_DIR
: /tmp
  MYSQL_DSN: mysql:unix_socket=/
cloudsql/zoho-portal-159018:us-central1:zoho-portal;dbname=zoho_portal
  MYSQL_USER
: USER
  MYSQL_PASSWORD
: PASS

However, when I query my database using eloquent I receive this error:

SQLSTATE[HY000] [2002] Connection refused


I followed this guideline: https://cloud.google.com/sql/docs/mysql/connect-app-engine?hl=en_US&_ga=1.259065737.2061084871.1491404918



Justin Beckwith

unread,
Apr 28, 2017, 10:34:13 AM4/28/17
to google-a...@googlegroups.com
Greetings!  You probably should be following this guide:

Specifically, looks like you're missing this piece:

# Use the connection name obtained when configuring your Cloud SQL instance.
beta_settings:
    cloud_sql_instances: "CONNECTION_NAME"

Good luck!

--
You received this message because you are subscribed to the Google Groups "Google App Engine" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-appengine+unsubscribe@googlegroups.com.
To post to this group, send email to google-appengine@googlegroups.com.
Visit this group at https://groups.google.com/group/google-appengine.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-appengine/3b1065c1-e6e5-4247-9db2-d5f3cf2e77a9%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--

Justin Beckwith | Google Cloud Platform | @justinbeckwith | http://jbeckwith.com

Adeel Ahmad

unread,
Apr 28, 2017, 2:14:15 PM4/28/17
to Google App Engine
Hello Justin,

Thank you for the reply.

I have updated my app.yaml file according to the guideline you linked.

runtime: php
env
: flex

runtime_config
:
  document_root
: public

# required on some platforms so ".env" is not skipped
skip_files
: false

env_variables
:
 
# The values here will override those in ".env". This is useful for
 
# production-specific configuration. However, feel free to set these
 
# values in ".env" instead if you prefer.
  APP_LOG
: errorlog
  STORAGE_DIR
: /tmp
  MYSQL_DSN: mysql:unix_socket=/
cloudsql/zoho-portal-159018:us-central1:zoho-portal;dbname=
zoho_portal
  MYSQL_USER
: adeel
  MYSQL_PASSWORD
: 118097

beta_settings
:
    cloud_sql_instances
: zoho-portal-159018:us-central1:zoho-portal

However, I'm still getting the same error. Could there be anything else that I'm missing out?

Justin Beckwith

unread,
Apr 28, 2017, 2:19:21 PM4/28/17
to google-a...@googlegroups.com, Takashi Matsuo, Brent Shaffer
+ a few PHP folks

--
You received this message because you are subscribed to the Google Groups "Google App Engine" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-appengine+unsubscribe@googlegroups.com.
To post to this group, send email to google-appengine@googlegroups.com.
Visit this group at https://groups.google.com/group/google-appengine.

For more options, visit https://groups.google.com/d/optout.

Jordan (Cloud Platform Support)

unread,
May 2, 2017, 1:34:31 PM5/2/17
to Google App Engine
Google Groups is meant for general product discussions and not for technical support.

If you require technical aid in connecting to your Cloud SQL instance from App Engine, you can post your setup and stacktrace on Stack Overflow using the Google Cloud tags as our technical community support team is active there. 

Note: you have posted the user and password for your SQL machine publicly. It is highly recommended you change this information

Takashi Matsuo

unread,
May 2, 2017, 5:06:06 PM5/2/17
to Google App Engine

Hi Adeel,
Just to make sure, you're sending the fake password in the previous e-mail, right? If not, I recommend you change it.

--
You received this message because you are subscribed to the Google Groups "Google App Engine" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-appengi...@googlegroups.com.
To post to this group, send email to google-a...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.
--
-- Takashi

Adeel Ahmad

unread,
May 7, 2017, 11:37:24 PM5/7/17
to Google App Engine
I have asked my question on Stack Overflow with the required details (http://stackoverflow.com/questions/43823624/connection-refused-connecting-to-google-cloud-sql). Would be great if someone could respond.

Thank you.
Reply all
Reply to author
Forward
0 new messages