I wanted to connect to a remote MySQL host (with rake db:create ), but Rails always considers it local. Database.yml that uses the following configuration:
defaults: &defaults encoding: unicode adapter: mysql username: <username> password: ************* port: 3306 host: <remote ip address> development: <<: *defaults database: <db name> test: &test <<: *defaults database: <db name> production: <<: *defaults database: <db name>
And always get this error when trying something in the database:
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)
The configuration works as long as I use the local database (i.e. without the host / port part). Connecting to a remote MySQL server works fine with data.
Any ideas on what's going wrong?
Edit : The problem only arises with rake:db:create , other tasks work - the error message is really misleading.
database mysql ruby-on-rails
Homer J. simpson
source share