Remote connection to Google Cloud SQL

I am new to Google Cloud SQL (currently host our own on a VPS) and want to scale in the cloud with Google. Setup a 2nd Gen CloudSQL acct… and am trying to connect it to our WordPress site (uses a plugin to connect to external dbs).

Our Application uses the following four constants: user, pword, server and db.

$db_data["user"] = "user_name";
$db_data["password"] = "password";
$db_data["db_host"] = "Google_IPv4_address";
$db_data["db_name"] = "db_name_inside_the_Instance_ID";

Setup Google Cloud SQL Instance with following:
– IPv4 address (using that for our db_host)
– Authorized networks – have current static IP added for WP to connect to Google
– MySQL User Acct – have a special “User name” with credentials at current host (Host name) complete with our static IP.
– Only nuance is current mysql we are using is 5.6 and I am trying to connect to a 5.7 instance… Haven’t read why this would prevent application from connecting to the db.

Just to be clear – we are passing these over using mysqli method and passes the above credentials in similar format (some names change slightly when it processes a lookup to use local or external db):

function ConnectBase($db_server, $db_user, $db_password, $db_database) {
        $connection = mysqli_connect($db_server, $db_user, $db_password);

I’ve tested connecting to this instance whitelisting my local IP and can connect MySQL Workbench… but this was only after the first instance (Gen2 mysql 5.6 version) I created wouldn’t connect externally. This new one is Gen2 mysql 5.7 if that matters. I know everything is setup proper so connection on this instance would work but no dice. And I’ve read perhaps 200 different posts and can’t find a solution. So frustrating.

This is not hosted on Google (not a Google App Engine site). May go that direction in the future if speed tests work well – just need to connect to Google CloudSQL first 🙂

Hoping someone faced something similar and overcame this type of connection or even @Vadim can comment. Thanks everyone.

Read more here: Remote connection to Google Cloud SQL

Leave a Reply

Your email address will not be published. Required fields are marked *