Friday, April 17, 2009
How To Setup MySQL on Cygwin and Rails
I've been developing our app on Rails in a Windows Vista environment. I'm now working on integrating our scoring algorithm more closely with Python, which means I need the help of some libraries that don't compile under Windows. Thus, I've finally had to install Cygwin. Of course, it comes with it's share of problems. While I had to setup MySQL under Cygwin so I could get the MySQL gem installed, I wanted to use the MySQL instance in Windows. Another reason for that was because the MySQL build didn't complete properly - there are some problems with some of the extensions it needs under Cygwin. But it install enough after you modify the ./configure command (like this "./configure -without-libedit") and run the "make install" command.
You'll likely wind up with a socket error when you try to connect to your MySQL database on your Windows box if you keep your database.yml file the same. The error you may get looks like this: "can't connect to local Mysql Server through socket '/tmp/mysql.sock'"
To fix this, simply change your host in your database.yml file to point to: "host: 127.0.0.1" or wherever your host is. And that's it, problem solved.