Database Error?

Hello everyone,
I am getting this database connection error when I run a rake task or
when I try to send with ar_mailer. My app works fine that I know of
but I went to import users into the database and this is what I get.

rake db:load_csv_data --trace
(in /home/greatcar/gcp)
** Invoke db:load_csv_data (first_time)
** Invoke environment (first_time)
** Execute environment
** Execute db:load_csv_data
rake aborted!
Access denied for user ‘root’@‘localhost’ (using password: NO)
/usr/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record/
connection_adapters/mysql_adapter.rb:548:in real_connect' /usr/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record/ connection_adapters/mysql_adapter.rb:548:inconnect’
/usr/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record/
connection_adapters/mysql_adapter.rb:198:in initialize' /usr/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record/ connection_adapters/mysql_adapter.rb:74:innew’
/usr/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record/
connection_adapters/mysql_adapter.rb:74:in mysql_connection' /usr/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record/ connection_adapters/abstract/connection_pool.rb:223:insend’
/usr/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record/
connection_adapters/abstract/connection_pool.rb:223:in
new_connection' /usr/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record/ connection_adapters/abstract/connection_pool.rb:245:incheckout_new_connection’
/usr/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record/
connection_adapters/abstract/connection_pool.rb:188:in checkout' /usr/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record/ connection_adapters/abstract/connection_pool.rb:184:inloop’
/usr/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record/
connection_adapters/abstract/connection_pool.rb:184:in checkout' /usr/lib/ruby/1.8/monitor.rb:242:insynchronize’
/usr/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record/
connection_adapters/abstract/connection_pool.rb:183:in checkout' /usr/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record/ connection_adapters/abstract/connection_pool.rb:98:inconnection’
/usr/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record/
connection_adapters/abstract/connection_pool.rb:326:in
retrieve_connection' /usr/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record/ connection_adapters/abstract/connection_specification.rb:121:inretrieve_connection’
/usr/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record/
connection_adapters/abstract/connection_specification.rb:113:in
connection' /usr/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record/ base.rb:1220:incolumns’
/usr/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record/
base.rb:2839:in attributes_from_column_definition_without_lock' /usr/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record/ locking/optimistic.rb:55:inattributes_from_column_definition’
/usr/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record/
base.rb:2279:in initialize' /home/greatcar/gcp/lib/tasks/import.rake:9:innew’
/home/greatcar/gcp/lib/tasks/import.rake:9
/usr/lib/ruby/gems/1.8/gems/fastercsv-1.4.0/lib/faster_csv.rb:1514:in
each' /usr/lib/ruby/gems/1.8/gems/fastercsv-1.4.0/lib/faster_csv.rb:1017:inforeach’
/usr/lib/ruby/gems/1.8/gems/fastercsv-1.4.0/lib/faster_csv.rb:1191:in
open' /usr/lib/ruby/gems/1.8/gems/fastercsv-1.4.0/lib/faster_csv.rb:1016:inforeach’
/home/greatcar/gcp/lib/tasks/import.rake:8
/usr/lib/ruby/gems/1.8/gems/rake-0.8.3/lib/rake.rb:617:in call' /usr/lib/ruby/gems/1.8/gems/rake-0.8.3/lib/rake.rb:617:inexecute’
/usr/lib/ruby/gems/1.8/gems/rake-0.8.3/lib/rake.rb:612:in each' /usr/lib/ruby/gems/1.8/gems/rake-0.8.3/lib/rake.rb:612:inexecute’
/usr/lib/ruby/gems/1.8/gems/rake-0.8.3/lib/rake.rb:578:in
invoke_with_call_chain' /usr/lib/ruby/1.8/monitor.rb:242:insynchronize’
/usr/lib/ruby/gems/1.8/gems/rake-0.8.3/lib/rake.rb:571:in
invoke_with_call_chain' /usr/lib/ruby/gems/1.8/gems/rake-0.8.3/lib/rake.rb:564:ininvoke’
/usr/lib/ruby/gems/1.8/gems/rake-0.8.3/lib/rake.rb:2019:in
invoke_task' /usr/lib/ruby/gems/1.8/gems/rake-0.8.3/lib/rake.rb:1997:intop_level’
/usr/lib/ruby/gems/1.8/gems/rake-0.8.3/lib/rake.rb:1997:in each' /usr/lib/ruby/gems/1.8/gems/rake-0.8.3/lib/rake.rb:1997:intop_level’
/usr/lib/ruby/gems/1.8/gems/rake-0.8.3/lib/rake.rb:2036:in
standard_exception_handling' /usr/lib/ruby/gems/1.8/gems/rake-0.8.3/lib/rake.rb:1991:intop_level’
/usr/lib/ruby/gems/1.8/gems/rake-0.8.3/lib/rake.rb:1970:in run' /usr/lib/ruby/gems/1.8/gems/rake-0.8.3/lib/rake.rb:2036:instandard_exception_handling’
/usr/lib/ruby/gems/1.8/gems/rake-0.8.3/lib/rake.rb:1967:in run' /usr/lib/ruby/gems/1.8/gems/rake-0.8.3/bin/rake:31 /usr/local/bin/rake:19:inload’
/usr/local/bin/rake:19

Thanks for the help,

Sean McGilvray

On Mar 25, 6:41 pm, Sean McGilvray [email protected] wrote:

** Execute db:load_csv_data
rake aborted!
Access denied for user ‘root’@‘localhost’ (using password: NO)

Should it be connecting as root ?

Fred

No, my database.yml has the correct settings:

production:
adapter: mysql
database: DB_NAME
username: USER_NAME
password: PASSWORD
host: 127.0.0.1

Sean McGilvray
Executive Director
Identity Theft Specialist
Pre-Paid Legal Service’s, Inc. NYSE:PPD
Phone: 760-486-1019
[email protected]
http://www.transferhome.net

On Wed, Mar 25, 2009 at 11:47 AM, Frederick C. <

Yes that works. How do I fix the problem of the correct environment not
loading?

Sean McGilvray & Sarena Byers
Director
Identity Theft Specialist
Pre-Paid Legal Service’s, Inc. NYSE:PPD
Phone: 760-486-1019
[email protected]
http://www.transferhome.net

On Wed, Mar 25, 2009 at 12:03 PM, Frederick C. <

On Mar 25, 6:58 pm, Sean McGilvray [email protected] wrote:

No, my database.yml has the correct settings:

which implies that the correct environment isn’t loaded. does
RAILS_ENV=production rake db:load_csv_data
work any better?

Fred

On Mar 25, 8:24 pm, Sean McGilvray [email protected] wrote:

Yes that works. How do I fix the problem of the correct environment not
loading?

Looks like nothing set the RAILS_ENV environment variable and so it
defaulted to development (things that run apps such as mongrel or
passenger usually have this as an explicit option in the
configuration). You need to either:

  • always specify RAILS_ENV when doing something
  • fiddle with the files appropriate to your shell and operating system
    so that the environment variable is always set for you.

Fred

I figured out why this was happening.

I switched to RAILS_ENV=‘production’

ENV[“RAILS_ENV”] has been deprecated.

I did not know that ENV[“RAILS_ENV”] has been deprecated.

Thanks for the help.

Sean McGilvray
Executive Director
Identity Theft Specialist
Pre-Paid Legal Service’s, Inc. NYSE:PPD
Phone: 760-486-1019
[email protected]
http://www.transferhome.net

On Wed, Mar 25, 2009 at 2:39 PM, Frederick C. <

It isn’t deprecated, it just not always set, as in the dev
environment, for example.

Maurício Linhares
http://alinhavado.wordpress.com/ (pt-br) | http://blog.codevader.com/
(en)

Several post that I have read say that it is deprecated. When I
switched
from using

ENV[‘RAILS_ENV’] ||= ‘production’

to using

RAILS_ENV=‘production’

in my environment file my app now loads in production just fine. When I
was
using ENV[‘RAILS_ENV’] ||= ‘production’ it kept coming up in
development.

Sean McGilvray
Execitve Director
Identity Theft Specialist
Pre-Paid Legal Service’s, Inc. NYSE:PPD
Phone: 760-486-1019
[email protected]
http://www.transferhome.net

2009/3/25 Maurício Linhares [email protected]

I’m not really sure where you saw this, but all of those posts are
clearly wrong.

This is what you’re going to find at the rails initializer:

RAILS_ENV = (ENV[‘RAILS_ENV’] || ‘development’).dup unless
defined?(RAILS_ENV)

The RAILS_ENV environment variable is where Rails is usually going to
find out at which environment it is (this is specially true at Rake
tasks), your code shouldn’t depend on it, as you should get the
current Rails env by doing “Rails.env” (instead of using the constant
as you are), but it is not deprecated. It’s just not meant to be used
the way you were trying to.

And instead of using RAILS_ENV, try using Rails.env.

Maurício Linhares
http://alinhavado.wordpress.com/ (pt-br) | http://blog.codevader.com/
(en)