Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I connect to a Google Cloud MySQL database using DataGrip?

Tags:

mysql

datagrip

I am new to Google Cloud SQL and new to DataGrip. I've created a database in GC, but have not modified it yet.

My question is, how do I connect the two?

Specifically, what do I put in the following fields: Host, User and URL

Is the User field my Google username? Or something else?

Thanks in advance for helping a noob!

enter image description here

like image 867
Slot Machine Avatar asked Apr 10 '26 21:04

Slot Machine


1 Answers

I haven't used DataGrip before, but my guess is that User is going to be your DB user, Host is going to be the IP for the Cloud SQL instance, and leave URL blank (it says in the UI there that it overrides other settings, so you shouldn't need it).

My suggestion would be to setup the Cloud SQL proxy (documentation on how to do so can be found here: https://cloud.google.com/sql/docs/mysql/connect-admin-proxy). The proxy is a binary that you'll run locally with DataGrip that will handle the communication between you and Cloud SQL.

It will walk you through setting up the proxy, which then will allow you to put 'localhost' in that Host field, while still securely connecting to your Cloud SQL instance without having to worry about other settings. If you don't do it, then you'll need to authorize the IP address of where you're connecting from in the Cloud SQL settings which is less secure.

like image 151
Gabe Weiss Avatar answered Apr 12 '26 09:04

Gabe Weiss