i started a tunnel using the usual ssh command line options:
ssh -p 22 -L 3307:localhost:3306 us...@remotehost.domain.com
then in database.yml
THIS WORKS
development:
adapter: mysql
encoding: utf8
database: dev_data
username: dev_admin
password: password
host: 127.0.0.1
port: 3307
THIS FAILS
development:
adapter: mysql
encoding: utf8
database: dev_data
username: dev_admin
password: password
host: localhost
port: 3307
It seems that the adapter will automatically force a mysql.sock to be
used when host: is set to localhost.
Switching host: to the actual IP seems to allow the port option to go
into effect.
Just wanted to post this so others may find the solution I did, more
quickly.
--
Posted via http://www.ruby-forum.com/.
> THIS WORKS
> host: 127.0.0.1
>
> THIS FAILS
> host: localhost
>
> It seems that the adapter will automatically force a mysql.sock to be
> used when host: is set to localhost.
Yes, I've noticed this myself; it's not particular to Rails. I have to
do this when using CocoaMySQL to connect to my remote database via ssh
tunnel. I sure would like to know why it works this way too... Is
"localhost" just a magic keyword for using the socket?
--Andrew Vit
> then in database.yml
> THIS WORKS
>
> development:
> adapter: mysql
> encoding: utf8
> database: dev_data
> username: dev_admin
> password: password
> host: 127.0.0.1
> port: 3307