Remote mySQL Database


Tried to configure the database.yml file to point to a remote mysql
database but faced an error "Connection refused - connect(2)".

Here's a copy of my database.yml configuration.

  adapter: mysql
  encoding: utf8
  host: <hostname>
  port: <portnumber>
  database: <databasename>
  username: <username>
  password: <password>
  socket: <socketpath>

Would appreciate any assistance in this area, as I can't seem to find
any articles on Ruby connecting to a remote mysql database. I'm sure
that the username and password works. Is there something that I might
missed out?

Thanks! = ]

Hi marTyN,

This post probably belongs on a MySQL mailing list, not a Rails one, but...

It appears that you need to configure the MySQL permissions on your remote database server to allow remote connections from your "originating" host (for the username/password combo you configure in your yml file). The other thing to check is that the firewall on your remote server allows incoming connections (on port 3306 - by default).



WAG: remove the 'socket' entry



I have the exact same problem for connecting to remote DB.

1) This is not a mysql issue, as I can remotely connect to the server
user mysql-client

2) I don't have the host option in my database.yml

I made a typo, one should read:

2) I don't have the socket option in database.yml

Anyway, I could go a step further by installing gem mysql, and now I

Can't connect to MySQL server on '' (111)

does this:

# telnet 3306

give you this:

Connected to (
Escape character is '^]'.


do you have the mysql client locally? you could try this:

# mysql -h -u username -p

Here is an example of the database.yml:

I just confirmed that I can connect to a remote db with both an older
(1.2.3) and a newer (2.0.2) rails app.

Do a `show grants` from a mysql client to make sure your permissions
are set right.