TOTD #35: Rails Database Connection on Solaris

Are you deploying your JRuby-on-Rails applications on Solaris (or any variety of Unix) and not able to connect to the database ?

I experienced it last week so thought of sharing the tip here. Luckily it's really simple.

Here is the default generated "config/database.yml"

development:

  adapter: mysql

  encoding: utf8

  database: runner_development

  username: root

  password:

  socket: /tmp/mysql.sock

The only required change is to add "host: 127.0.01" for the required database configuration. The updated fragment is shown below (with change highlighted):

development:

  adapter: mysql

  encoding: utf8

  database: runner_development

  username: root

  password:

  socket: /tmp/mysql.sock

  host: 127.0.01

Even though "host" is required for TCP connections but the database connection does not seem to work without this entry. The exact same application works without "host" entry on Windows and Mac OS.

Alternatively, you can always install the JDBC adapter as explained here.

Please leave suggestions on other TOTD (Tip Of The Day) that you'd like to see. A complete archive is available here.

Technorati: totd rubyonrails jruby ruby opensolaris mysql

This story, "TOTD #35: Rails Database Connection on Solaris" was originally published by JavaWorld.

Copyright © 2008 IDG Communications, Inc.