I'm able to connect to the remote database from a MySQL client and using terminal as well. But when trying to access the database from the Rails app, I got this error:
Mysql2::Error (Can't connect to MySQL server on 'myhost.com' (4))
My database.yml has the following configuration for development:
adapter: mysql2
encoding: utf8
reconnect: false
host: myhost.com
port: 3306
database: the_database
pool: 5
username: myusername
password: mypassword
socket: /var/lib/mysql/mysql.sock
I have changed the name of the host to post this question, as the username, password and database.
Googling around, I could see different reasons for not connecting to the database, but none of them are similar to mine and with this code 4 (is that an error code?).
I'm new to Rails, so I have no clue what should I do next in order to fix it. I have double checked my configuration, even the socket. I've personally checked on the server side and this is the right path to the socket.
I'm not sure if it's relevant, but this user has read only access to this database.
I'm using Rails 3.2.8 and Ruby 1.8.7.