Remote MySQL server and Ruby on Rails

Hello,

I have 1 DB server (MySQL) and 1 server with my application. I’ve
setup the host in my database.yml file to match my DB server. When I
run the application, I get this error:

Errno::ENOENT in TestController#index
No such file or directory - /tmp/mysql.sock

— Full Trace —
/usr/local/lib/ruby/gems/1.8/gems/activerecord-2.1.0/lib/active_record/
vendor/mysql.rb:107:in initialize' /usr/local/lib/ruby/gems/1.8/gems/activerecord-2.1.0/lib/active_record/ vendor/mysql.rb:107:innew’
/usr/local/lib/ruby/gems/1.8/gems/activerecord-2.1.0/lib/active_record/
vendor/mysql.rb:107:in real_connect' /usr/local/lib/ruby/gems/1.8/gems/activerecord-2.1.0/lib/active_record/ connection_adapters/mysql_adapter.rb:505:inconnect’
/usr/local/lib/ruby/gems/1.8/gems/activerecord-2.1.0/lib/active_record/
connection_adapters/mysql_adapter.rb:183:in initialize' /usr/local/lib/ruby/gems/1.8/gems/activerecord-2.1.0/lib/active_record/ connection_adapters/mysql_adapter.rb:88:innew’
/usr/local/lib/ruby/gems/1.8/gems/activerecord-2.1.0/lib/active_record/
connection_adapters/mysql_adapter.rb:88:in mysql_connection' /usr/local/lib/ruby/gems/1.8/gems/activerecord-2.1.0/lib/active_record/ connection_adapters/abstract/connection_specification.rb:292:insend’
/usr/local/lib/ruby/gems/1.8/gems/activerecord-2.1.0/lib/active_record/
connection_adapters/abstract/connection_specification.rb:292:in
connection=' /usr/local/lib/ruby/gems/1.8/gems/activerecord-2.1.0/lib/active_record/ connection_adapters/abstract/connection_specification.rb:260:inretrieve_connection’
/usr/local/lib/ruby/gems/1.8/gems/activerecord-2.1.0/lib/active_record/
connection_adapters/abstract/connection_specification.rb:78:in
connection' /usr/local/lib/ruby/gems/1.8/gems/activerecord-2.1.0/lib/active_record/ query_cache.rb:8:incache’
/usr/local/lib/ruby/gems/1.8/gems/actionpack-2.1.0/lib/
action_controller/caching/sql_cache.rb:12:in perform_action' /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.1.0/lib/ action_controller/base.rb:529:insend’
/usr/local/lib/ruby/gems/1.8/gems/actionpack-2.1.0/lib/
action_controller/base.rb:529:in process_without_filters' /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.1.0/lib/ action_controller/filters.rb:569:inprocess_without_session_management_support’
/usr/local/lib/ruby/gems/1.8/gems/actionpack-2.1.0/lib/
action_controller/session_management.rb:130:in process' /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.1.0/lib/ action_controller/base.rb:389:inprocess’
/usr/local/lib/ruby/gems/1.8/gems/actionpack-2.1.0/lib/
action_controller/dispatcher.rb:149:in handle_request' /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.1.0/lib/ action_controller/dispatcher.rb:107:indispatch’
/usr/local/lib/ruby/1.8/thread.rb:135:in synchronize' /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.1.0/lib/ action_controller/dispatcher.rb:104:indispatch’
/usr/local/lib/ruby/gems/1.8/gems/actionpack-2.1.0/lib/
action_controller/dispatcher.rb:120:in dispatch_cgi' /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.1.0/lib/ action_controller/dispatcher.rb:35:indispatch’
/usr/local/lib/ruby/gems/1.8/gems/rails-2.1.0/lib/fcgi_handler.rb:
103:in process_request' /usr/local/lib/ruby/gems/1.8/gems/rails-2.1.0/lib/fcgi_handler.rb: 153:inwith_signal_handler’
/usr/local/lib/ruby/gems/1.8/gems/rails-2.1.0/lib/fcgi_handler.rb:
101:in process_request' /usr/local/lib/ruby/gems/1.8/gems/rails-2.1.0/lib/fcgi_handler.rb: 78:inprocess_each_request’
/usr/local/lib/ruby/gems/1.8/gems/fcgi-0.8.7/lib/fcgi.rb:612:in
each_cgi' /usr/local/lib/ruby/gems/1.8/gems/fcgi-0.8.7/lib/fcgi.rb:609:ineach’
/usr/local/lib/ruby/gems/1.8/gems/fcgi-0.8.7/lib/fcgi.rb:609:in
each_cgi' /usr/local/lib/ruby/gems/1.8/gems/rails-2.1.0/lib/fcgi_handler.rb: 77:inprocess_each_request’
/usr/local/lib/ruby/gems/1.8/gems/rails-2.1.0/lib/fcgi_handler.rb:
76:in catch' /usr/local/lib/ruby/gems/1.8/gems/rails-2.1.0/lib/fcgi_handler.rb: 76:inprocess_each_request’
/usr/local/lib/ruby/gems/1.8/gems/rails-2.1.0/lib/fcgi_handler.rb:
50:in process!' /usr/local/lib/ruby/gems/1.8/gems/rails-2.1.0/lib/fcgi_handler.rb: 24:inprocess!’
/path/to/my/public_html/public/dispatch.fcgi:26


— database.yml —
development:
adapter: mysql
encoding: utf8
database: Test_App_development
username: root
password:
host: dbserver

test:
adapter: mysql
encoding: utf8
database: Test_App_test
username: root
password:
host: dbserver

production:
adapter: mysql
encoding: utf8
database: Test_App_production
username: root
password:
host: dbserver


The MySQL gem is installed. I’m not sure what’s wrong…

Any help is appreciated!

Thank you,

  • wedix

I think the socket on which your remote server is different from
/tmp/mysql.sock.
Just check with the socket and then place the same thing on the
database.yml
.
cheers,
kranthi

production:
adapter: mysql
encoding: utf8
database: Test_App_production
username: root
password:
host: dbserver

You may need to specify a port number, and/or protocol: tcp. GL!
-R