Tunnelling through SSH to MySql instance


I want to tunnel a mysql connection to a database behind a firewall. I can connect to the database from a terminal using a tunnel to the host machine if I specify --protocol like this:

mysql -u xxxx -h localhost -P 3322 -p --protocol tcp

I originally thought that specifying a port number would switch mysql into tcp mode instead of looking for a socket, but that doesn't seem to be the case.

So the problem is, how can I tell rails to use the --protocol argument when connecting to my database? The documentation for ActiveRecord::ConnectionAdapters::MysqlAdapter doesn't offer a protocol option.

Any ideas people?



Nevermind, I've solved this by trawling the internet.

So for future reference, if you specify the host as an IP address then the mysql client will flip to use TCP/IP, so simply change the host arguments value in the database.yml file to an IP ( for localhost and tunnelling).