Can’t Find the Database?

When using MySQL with Rails, even following a successful installation of MySQL, Rails may display an error message similar to the following when you try to run your application:

no such file to load -- mysql

Some versions of Rails (Rails 2.2 and newer) require that the MySQL gem be installed as a separate operation. To do this, enter the following at the system prompt:

gem install mysql

Another problem may arise on Windows. When you run your application, it is possible that you will see an error message similar to this:

The specified module could not be found.
c:/ruby/lib/ruby/gems/1.8/gems/mysql-2.7.3-x86-mswin32/ext/mysql.so

If you encounter this problem, you should be able to fix it by making a copy of a file called libmySQL.dll from your MySQL binary directory (for example, C:\Program Files\MySQL\MySQL Server 5.0\bin) into the Ruby binary directory (for example, C:\ruby\bin). Restart your application (shut down and restart the server), and then try running it again.