Superset Connect to a private database

Viewed 1078

I have a database running in a private VPC. The database isn't publicly accessible. Does superset support Connecting to databases via an SSH Tunnel? If so any link to the docs?

2 Answers

I couldn't find it in the docs, but with the SSH tunnel you basically need to change the DB host to 127.0.0.1 (not localhost, since that's a keyword reserved for connection using the MySQL socket), and everything else should be the same.

For example, I tested with a MySQL database that I have running on host.example.com. I first created a tunnel redirecting my local port 3336 to MySQL's port 3306 (I did that because I already have MySQL running locally on 3306):

ssh -N -L 3336:127.0.0.1:3306 host.example.com

Then I was able to add it to Superset using this SQLAlchemy URI:

mysql://username:password@127.0.0.1:3336/dbname

This worked for me:

ssh -i /path/key-pair_instance1.pem username_of_instance1@i-0123456789abcdefa -L 9090:ec2-198-51-100-2.compute-1.amazonaws.com:3306

Here is the source with further explanation.

Related