MySQL connection is not working for Laravel at Google Cloud SQL

504 views
Skip to first unread message

Dilip Dexbytes

unread,
Jun 4, 2018, 8:59:45 AM6/4/18
to Google Cloud SQL discuss
Hi,

I have been trying to connect the MySQL on google cloud for Laravel application, i have configured the app.yaml file as per the documents featured on internet. But don't know whats wrong with GCloud, it won't connect anyway.

Can someone please help me.


Below is app.yaml file

runtime: php
env: flex
runtime_config:
 document_root: public   #folder where index.php is
# Ensure we skip ".env", which is only for local development
skip_files:
 - .env #we want to skip this to make sure we don’t mess stuff up on the server
env_variables:
 # Put production environment variables here.
 APP_ENV:  production
 APP_DEBUG: true
 APP_KEY: base64:5efXAk7MFz9HoBbRP55vxgu6eu+sFeBEOp/lhHzXc6s=
#go to generate app key paragraf in this tutorial
 CACHE_DRIVER: file
# instead of putting the cache in the database I recommend using redis
 SESSION_DRIVER: file
 APP_LOG: daily
 #APP_TIMEZONE: UTC #your timezone of choice
# follow the part of the tutorial on setting up your SQL database
 DB_CONNECTION: mysql
 DB_HOST: localhost
 DB_DATABASE: submit_itr_v1
 DB_USERNAME: root
 DB_PASSWORD: somepassword
 DB_SOCKET: "/cloudsql/<Instance connection name>"
 DB_PORT: 3306
 STORAGE_DIR: /tmp
 MYSQL_DSN: "mysql:dbname=db_name;unix_socket="/cloudsql/intance-connection-name"
 MYSQL_USER: root


Thanks,
Dilip

Jordan (Cloud Platform Support)

unread,
Jun 4, 2018, 6:35:33 PM6/4/18
to google-cloud...@googlegroups.com
If your Cloud SQL instance and App Engine application are in different projects, you must ensure that you follow the documentation to granting your App Engine application access to your SQL instance. 

Also ensure that you follow the Setting Connection Strings guide as shown exactly, as I see that you have added '"' quotes around your 'MYSQL_DSN' and are not using the 'cloud_sql_instances' beta setting which is required.

- Note, Google Groups is reserved for general product discussions and is not for technical support. For further technical support it is recommended to post your detailed questions to Stack Exchange using the supported Cloud tags. 
Reply all
Reply to author
Forward
0 new messages