Wordpress Remote Connect to Cloud SQL - Error establishing a database connection

377 views
Skip to first unread message

Jun Leong Wong

unread,
Mar 27, 2020, 9:21:20 AM3/27/20
to Google Cloud SQL discuss
Hi,

I have an existing wordpress running on my own server and now I want to migrate my database to Google Cloud SQL 


The following I have set in my wp-config.php

I have added my server outgoing, incoming, and cloudflare ip into public ip



define('DB_NAME', 'myblog'); //under MySQL databases

/** MySQL database username */
define('DB_USER', 'myusername');  //under username created under MySQL user accounts

/** MySQL database password */
define('DB_PASSWORD', 'mypass');   //under password created under MySQL user accounts

/** MySQL hostname */
define('DB_HOST', '35.227.86.242');  //under Connect to this instance > Public IP address

/** Database Charset to use in creating database tables. */
define('DB_CHARSET', 'utf8');

/** The Database Collate type. Don't change this if in doubt. */
define('DB_COLLATE', 'utf8_general_ci');



However, I got Error establishing a database connection error.

Helps needed.

Thank you.

George (Cloud Platform Support)

unread,
Mar 27, 2020, 3:16:48 PM3/27/20
to Google Cloud SQL discuss
Did you independently verify that your Cloud SQL instance accepts connections? You may refer to the "Connecting to Cloud SQL from external applications" documentation page for details. Have you followed the steps on this page for your setup? Is there any instruction that still has to be executed? 

You can grant any application access to a Cloud SQL instance by authorizing the public IP addresses that the application uses to connect. Have you executed this step, in your Cloud SQL setup? 

You may have been affected by a general Cloud SQL issue, just recently solved, as indicated on Google Cloud Status Dashboard. This issue is fixed now, so you should try connecting again, to determine if this was in fact your problem. 

Jun Leong Wong

unread,
Mar 28, 2020, 12:28:53 AM3/28/20
to Google Cloud SQL discuss
Hi,

Thanks for quick respond.

After adding CIDR notation /32 into my ip and restarted my instance, it finally works now.

Thanks a lot.

Have a great day.

George (Cloud Platform Support)

unread,
Mar 30, 2020, 8:00:48 AM3/30/20
to Google Cloud SQL discuss
Hi Jun, 

Glad to see you have fixed your issue. You are welcome opening separate issues in the Public Issue Tracker, if you are faced with other Cloud Platform related problems, or questions in stackoverflow for strictly programming-related matter. 
Reply all
Reply to author
Forward
0 new messages