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
Comments:

Basically you don't need

'socket: /tmp/mysql.sock'

socket or host are mmutually exclusive, looks like if host entry is there it takes over socket.

Looks like there is some bug with handling unix domain socket, use -J-Djruby.native.enabled=false on the jruby CLI and you wont see any issue. See a thread on this atusers@jruby[1].

[1]http://markmail.org/search/list:org.codehaus.jruby?q=vivek+pandey#query:vivek%20pandey+page:1+mid:6d6rn6v2mlfrhzcs+state:results

Posted by vivek on June 23, 2008 at 02:54 AM PDT #

[Trackback] My primary development machine is Mac OS Leopard on Intel Core 2 Duo (read osxtips). But the beauty of virtualization is that I can run multiple Operating Systems on a single powerful machine. And what better virtualization product than...

Posted by Arun Gupta's Blog on June 23, 2008 at 11:22 PM PDT #

One other step I needed was to add my port info. For instance:

development:
adapter: mysql
encoding: utf8
database: my_db_name_here
username: root
password: root
host: 127.0.0.1
port: 8889

Am running MySQL as part of the MAMP bundle; am guessing my port isn't the default.

Cheers,
Bobby

Posted by Bobby Bissett on August 21, 2008 at 04:41 AM PDT #

Post a Comment:
Comments are closed for this entry.
About

profile image
Arun Gupta is a technology enthusiast, a passionate runner, author, and a community guy who works for Oracle Corp.


Java EE 7 Samples

Stay Connected

Search

Archives
« July 2014
SunMonTueWedThuFriSat
  
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
  
       
Today