04 August 2012

SOLVED: Rails setup error with mysql

I had this problem setting up rails and mysql2.  Even though I had a database in Mysql, and a user created with appropriate rights granted... i would always get this error when hitting the rails app I made:
Can't connect to MySQL server on 'localhost' (10061) mysql

I searched and searched. I tried a variety of solutions, but then ran across one seeming odd solution.  There was a simple post on a website about going into the /config/database.yml file and changing the line:
host: localhost
to
host: 127.0.0.1

THAT WORKED.

How crazy is that?  The webserver knows localhost is 127.0.0.1, but for some reason this needed to be specified to an IP Address in the database.yml file!!

No comments:

Post a Comment