Rails db connection problem


#1

Hi,

I get the error in the log file, which indicates a database connection problem. I have constructed the db with migrate in production mode. Below the message, I attach my database.yml
file, just in case I made some mistake. I am running rails from a subdirectory of www.tangotallahassee.com/ and I did link the public/ appropriately. Any ideas would be appreciated. thanks.

Gordon

==== Extraction from log file======

Processing CalendarController#index (for 71.229.23.221 at 2007-07-17 10:09:09) [GET]
Session ID: 36db0d09a2f2baed1c99553378efc327
Parameters: {“action”=>“index”, “controller”=>“calendar”}

Mysql::Error (Can’t connect to local MySQL server through socket ‘/var/run/mysqld/mysqld.sock’ (2)):
/usr/lib/ruby/gems/1.8/gems/activerecord-1.15.3/lib/active_record/connection_adapters/mysql_adapter.rb:389:in real_connect' /usr/lib/ruby/gems/1.8/gems/activerecord-1.15.3/lib/active_record/connection_adapters/mysql_adapter.rb:389:inconnect’

database.yml ============

development:
adapter: mysql
database: tango_web_ajax_development
username: xxxxx
password: xxxxx
host: polls-mysql.tangotallahassee.com
port: 3306
#socket: /tmp/mysql.sock

Warning: The database defined as ‘test’ will be erased and

re-generated from your development database when you run ‘rake’.

Do not set this db to the same as development or production.

test:
adapter: mysql
database: tango_web_ajax_test
username: xxx
password: xxxx
host: polls-mysql.tangotallahassee.com
#socket: /tmp/mysql.sock
port: 3306

production:
adapter: mysql
database: tango_web_ajax_production
username: xxxxxx
password: xxxxx
host: polls-mysql.tangotallahassee.com
port: 3306

Gordon Erlebacher
School of Computational Science
Florida State University
Tallahassee, Florida


#2

Problem fixed. I simply removed the dispatch.fcgi processes and restarted the application. One item that is never mentioned in the wikis is that while one must set the RAIL_ENV to production mode in environment.rb, it is also important to set the environment in the current shell. Otherwise migrate will access the wrong database.

Gordon

Gordon Erlebacher
School of Computational Science
Florida State University
Tallahassee, Florida


#3

I got exactly the problem described but have no idea how to set the environment in my shell.