# Tunnelling through SSH to MySql instance

**URL:** <https://www.ruby-forum.com/t/tunnelling-through-ssh-to-mysql-instance/113368>\
**Category:** Rails\
**Created:** [August 30, 2007, 12:10pm UTC](https://www.ruby-forum.com/t/tunnelling-through-ssh-to-mysql-instance/113368 "2007-08-30T12:10:57Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![saha860](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/bcef8e/32.png) [@saha860](https://www.ruby-forum.com/u/saha860)\
**Post date:** [August 30, 2007, 12:10pm UTC](https://www.ruby-forum.com/t/tunnelling-through-ssh-to-mysql-instance/113368/1 "2007-08-30T12:10:57Z")

</div>

Hello,

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?

Thanks.

-Simon

---

<div class="post-metadata">

**Author:** ![saha860](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/bcef8e/32.png) [@saha860](https://www.ruby-forum.com/u/saha860)\
**Post date:** [August 30, 2007, 12:45pm UTC](https://www.ruby-forum.com/t/tunnelling-through-ssh-to-mysql-instance/113368/2 "2007-08-30T12:45:03Z")

</div>

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 (127.0.0.1 for  
localhost and tunnelling).

-Simon
