I use Tableau to explore my data, and usually my data is stored in MySQL on a database server that allows only local connections. Therefore, I need to use SSH tunneling to connect to my data. Tableau doesn’t support tunneling natively, but Macs are equipped with OpenSSH by default and make tunneling easy.
My database server allows only local connections through MySQL’s standard port using the
bind-address settings for MySQL. Here’s the relevant part of
# * Basic Settings
user = mysql
pid-file = /var/run/mysqld/mysqld.pid
socket = /var/run/mysqld/mysqld.sock
port = 3306
basedir = /usr
datadir = /var/lib/mysql
tmpdir = /tmp
lc-messages-dir = /usr/share/mysql
# Instead of skip-networking the default is now to listen only on
# localhost which is more compatible and is not less secure.
bind-address = 127.0.0.1
To use an SSH tunnel and Tableau to connect to a MySQL server:
- Open iTerm (or Terminal)
ssh -NC user@host -L 9999:127.0.0.1:3306
- Open Tableau
- Choose “Connect to data” from the Tableau start screen
- Choose “MySQL” from the Connect list
- Enter 127.0.0.1 and port 9999 into Tableau’s MySQL login window. Don’t forget to include your database username and password. Click “Connect”!
- When you’re done with Tableau, you can kill the tunnel with a
Make sure you have MySQL’s ODBC driver installed first, or no amount of tunneling will help you.
Use “127.0.0.1” as the server, not “localhost”.