Tuesday 5 May 2015

Connecting to Google Cloud SQL from SQuirreL SQL

Objective:

The objective of this post is to explain how to access Google Cloud SQL from third party tools like SQuirrel SQL.


About Google Cloud SQL:

Is a MySQL DB running in google cloud. This facility is charged by google based on type of instance we select.

https://cloud.google.com/sql/docs/introduction


About SQuirreL SQL:

SQuirrel SQL is an open source universal SQL client. It comes as a jar file and the concept that it uses to connect to SQL server is JDBC; thus we should have the corresponding JDBC driver for different types of databases.

http://squirrel-sql.sourceforge.net/


Accessing Google Cloud SQL server from SQuirrel SQL client:

The SQuirrel SQL is very much helpful in doing administration kind of work with databases.

Step 1: Create cloud sql instance in google developer console. The instance name is always prefixed with project name. While creating the instance, we need to select the type of instance and billing type.





Step 2: For safety and security, Google does not allow request from every IP to access the database. Hence we need to explicitly add our PC/laptop IP where SQuirrel SQL is running. Also we need to provide the public IP address and not the proxy IP.



Step 3: Create an user under 'Users' tab and provide % for client host

Step 4: SQuirrel SQL is not supporting IPV6, so we need to request IPV4 under IP address tab. Be aware if we are not using the IPV4 address then google will charge us. So once the work is completed, release IPV4 address.



Now all set in developer console. Now time to bring up SQuirrel SQL.

Step 5: When we launch SQuirrel SQL for the first time, the MySQL Driver may be missing, We can see the list of drivers in Driver tab.



Step 6: If the driver for MySQL is missing then download the mysql-connector-java-<x.x.x>-bin.jar and add it in class path as shown below.



Step 7: Create an aliases and provide proper JDBC URL and username & password given in developer console. Test the connection. The thing that will need change in the URL is the IP address and database name.