In ruby rake db:migrate show the password failure - ruby-on-rails

I am using rails with postgresql which is on remote machine. I have edited database.yml file according to the requirement.but when i run rake db:migrate it shows password failure.. but the same password works with the psql command..
the error when i run rake db:migrate is:
root#vdimc04 My_Postgres]# rake db:migrate --trace
** Invoke db:migrate (first_time)
** Invoke environment (first_time)
** Execute environment
** Invoke db:load_config (first_time)
** Execute db:load_config
** Execute db:migrate
rake aborted!
fe_sendauth: no password supplied
/usr/local/rvm/gems/ruby-1.9.3-p327/gems/activerecord-3.2.9/lib/active_record/connection_adapters/postgresql_adapter.rb:1208:in `initialize'
/usr/local/rvm/gems/ruby-1.9.3-p327/gems/activerecord-3.2.9/lib/active_record/connection_adapters/postgresql_adapter.rb:1208:in `new'
/usr/local/rvm/gems/ruby-1.9.3-p327/gems/activerecord-3.2.9/lib/active_record/connection_adapters/postgresql_adapter.rb:1208:in `connect'
/usr/local/rvm/gems/ruby-1.9.3-p327/gems/activerecord-3.2.9/lib/active_record/connection_adapters/postgresql_adapter.rb:326:in `initialize'
/usr/local/rvm/gems/ruby-1.9.3-p327/gems/activerecord-3.2.9/lib/active_record/connection_adapters/postgresql_adapter.rb:28:in `new'
/usr/local/rvm/gems/ruby-1.9.3-p327/gems/activerecord-3.2.9/lib/active_record/connection_adapters/postgresql_adapter.rb:28:in `postgresql_connection'
/usr/local/rvm/gems/ruby-1.9.3-p327/gems/activerecord-3.2.9/lib/active_record/connection_adapters/abstract/connection_pool.rb:315:in `new_connection'
/usr/local/rvm/gems/ruby-1.9.3-p327/gems/activerecord-3.2.9/lib/active_record/connection_adapters/abstract/connection_pool.rb:325:in `checkout_new_connection'
/usr/local/rvm/gems/ruby-1.9.3-p327/gems/activerecord-3.2.9/lib/active_record/connection_adapters/abstract/connection_pool.rb:247:in `block (2 levels) in checkout'
/usr/local/rvm/gems/ruby-1.9.3-p327/gems/activerecord-3.2.9/lib/active_record/connection_adapters/abstract/connection_pool.rb:242:in `loop'
/usr/local/rvm/gems/ruby-1.9.3-p327/gems/activerecord-3.2.9/lib/active_record/connection_adapters/abstract/connection_pool.rb:242:in `block in checkout'
/usr/local/rvm/rubies/ruby-1.9.3-p327/lib/ruby/1.9.1/monitor.rb:211:in `mon_synchronize'
/usr/local/rvm/gems/ruby-1.9.3-p327/gems/activerecord-3.2.9/lib/active_record/connection_adapters/abstract/connection_pool.rb:239:in `checkout'
/usr/local/rvm/gems/ruby-1.9.3-p327/gems/activerecord-3.2.9/lib/active_record/connection_adapters/abstract/connection_pool.rb:102:in `block in connection'
/usr/local/rvm/rubies/ruby-1.9.3-p327/lib/ruby/1.9.1/monitor.rb:211:in `mon_synchronize'
/usr/local/rvm/gems/ruby-1.9.3-p327/gems/activerecord-3.2.9/lib/active_record/connection_adapters/abstract/connection_pool.rb:101:in `connection'
/usr/local/rvm/gems/ruby-1.9.3-p327/gems/activerecord-3.2.9/lib/active_record/connection_adapters/abstract/connection_pool.rb:410:in `retrieve_connection'
/usr/local/rvm/gems/ruby-1.9.3-p327/gems/activerecord-3.2.9/lib/active_record/connection_adapters/abstract/connection_specification.rb:171:in `retrieve_connection'
/usr/local/rvm/gems/ruby-1.9.3-p327/gems/activerecord-3.2.9/lib/active_record/connection_adapters/abstract/connection_specification.rb:145:in `connection'
/usr/local/rvm/gems/ruby-1.9.3-p327/gems/activerecord-3.2.9/lib/active_record/migration.rb:662:in `initialize'
/usr/local/rvm/gems/ruby-1.9.3-p327/gems/activerecord-3.2.9/lib/active_record/migration.rb:570:in `new'
/usr/local/rvm/gems/ruby-1.9.3-p327/gems/activerecord-3.2.9/lib/active_record/migration.rb:570:in `up'
/usr/local/rvm/gems/ruby-1.9.3-p327/gems/activerecord-3.2.9/lib/active_record/migration.rb:551:in `migrate'
/usr/local/rvm/gems/ruby-1.9.3-p327/gems/activerecord-3.2.9/lib/active_record/railties/databases.rake:179:in `block (2 levels) in <top (required)>'
/usr/local/rvm/gems/ruby-1.9.3-p327#global/gems/rake-10.0.2/lib/rake/task.rb:227:in `call'
/usr/local/rvm/gems/ruby-1.9.3-p327#global/gems/rake-10.0.2/lib/rake/task.rb:227:in `block in execute'
/usr/local/rvm/gems/ruby-1.9.3-p327#global/gems/rake-10.0.2/lib/rake/task.rb:222:in `each'
/usr/local/rvm/gems/ruby-1.9.3-p327#global/gems/rake-10.0.2/lib/rake/task.rb:222:in `execute'
/usr/local/rvm/gems/ruby-1.9.3-p327#global/gems/rake-10.0.2/lib/rake/task.rb:166:in `block in invoke_with_call_chain'
/usr/local/rvm/rubies/ruby-1.9.3-p327/lib/ruby/1.9.1/monitor.rb:211:in `mon_synchronize'
/usr/local/rvm/gems/ruby-1.9.3-p327#global/gems/rake-10.0.2/lib/rake/task.rb:159:in `invoke_with_call_chain'
/usr/local/rvm/gems/ruby-1.9.3-p327#global/gems/rake-10.0.2/lib/rake/task.rb:152:in `invoke'
/usr/local/rvm/gems/ruby-1.9.3-p327#global/gems/rake-10.0.2/lib/rake/application.rb:141:in `invoke_task'
/usr/local/rvm/gems/ruby-1.9.3-p327#global/gems/rake-10.0.2/lib/rake/application.rb:99:in `block (2 levels) in top_level'
/usr/local/rvm/gems/ruby-1.9.3-p327#global/gems/rake-10.0.2/lib/rake/application.rb:99:in `each'
/usr/local/rvm/gems/ruby-1.9.3-p327#global/gems/rake-10.0.2/lib/rake/application.rb:99:in `block in top_level'
/usr/local/rvm/gems/ruby-1.9.3-p327#global/gems/rake-10.0.2/lib/rake/application.rb:108:in `run_with_threads'
/usr/local/rvm/gems/ruby-1.9.3-p327#global/gems/rake-10.0.2/lib/rake/application.rb:93:in `top_level'
/usr/local/rvm/gems/ruby-1.9.3-p327#global/gems/rake-10.0.2/lib/rake/application.rb:71:in `block in run'
/usr/local/rvm/gems/ruby-1.9.3-p327#global/gems/rake-10.0.2/lib/rake/application.rb:158:in `standard_exception_handling'
/usr/local/rvm/gems/ruby-1.9.3-p327#global/gems/rake-10.0.2/lib/rake/application.rb:68:in `run'
/usr/local/rvm/gems/ruby-1.9.3-p327#global/gems/rake-10.0.2/bin/rake:37:in `<top (required)>'
/usr/local/rvm/gems/ruby-1.9.3-p327#global/bin/rake:19:in `load'
/usr/local/rvm/gems/ruby-1.9.3-p327#global/bin/rake:19:in `<main>'
/usr/local/rvm/gems/ruby-1.9.3-p327/bin/ruby_noexec_wrapper:14:in `eval'
/usr/local/rvm/gems/ruby-1.9.3-p327/bin/ruby_noexec_wrapper:14:in `<main>'
Tasks: TOP => db:migrate
** my database.yml file**
development:
adapter: postgresql
encoding: unicode
database: db_pchamara
pool: 5
username: db_test_user
password: password
host: 192.168.1.101
port: 5432
test:
adapter: postgresql
encoding: unicode
database: db_pchamara_test
pool: 5
username: db_test_user
password: password
production:
adapter: postgresql
encoding: unicode
database: db_pchamara_production
pool: 5
username: db_test_user
password: password

Guys I got answer to my question...
When we start a new project with rails command like 'rails new demo' we have to include '--database=postgresql'. Then only the pg gem will gets to the bundle.. If it is not declared the pg gem will not comes to bundle..
And what i did in database.yml file is also correct. Everything is fine there...
When we use the database of postgresql to rails, we have to make some modifications to pg_hba.conf that is located in the lib directory..
I made some modifications there at my ip to TRUST where before it is md5..
we Can use both TRUST and md5.
md5- requires a passowrd to connect to database
trust- not requires a password
thats it.. as ususal include password to database.yml file.
Now the server runs without any error...
THANKS TO EVERYONE WHO HELPED ME TO FIGURE OUT THIS PROBLEM

Related

Ruby on rails fatal error (failed password authentification for user ****)

SORRY FOR MY BAD ENGLISH
When i tried to run my local server rails gave me this problem:
ActiveRecord :: ConnectionNotEstablished: FATAL: failed password authentication for user "Blog"
Caused by:
PG :: ConnectionBad: FATAL: failed authentication with password for user "Blog"
But my password was correct and also my username.
HERE MY YAML FILE
default: &default
adapter: postgresql
encoding: unicode
development:
<<: *default
database: Blog_development
encoding: UTF-8
username: Blog
password: Giungla
host: localhost
port: 5432
test:
<<: *default
database: Blog_test
production:
<<: *default
database: Blog_production
username: Blog
password: <%= ENV['BLOG_DATABASE_PASSWORD'] %>
THE TRACE IN MY TERMINAL
** rails db:migrate --trace
** Invoke db:migrate (first_time)
** Invoke db:load_config (first_time)
** Invoke environment (first_time)
** Execute environment
** Execute db:load_config
** Execute db:migrate
rails aborted!
ActiveRecord::ConnectionNotEstablished: FATALE: autenticazione con password fallita per l'utente "Blog"
C:/Ruby27-x64/lib/ruby/gems/2.7.0/gems/activerecord-6.1.4/lib/active_record/connection_adapters/postgresql_adapter.rb:83:in `rescue in new_client'
C:/Ruby27-x64/lib/ruby/gems/2.7.0/gems/activerecord-6.1.4/lib/active_record/connection_adapters/postgresql_adapter.rb:77:in `new_client'
C:/Ruby27-x64/lib/ruby/gems/2.7.0/gems/activerecord-6.1.4/lib/active_record/connection_adapters/postgresql_adapter.rb:37:in `postgresql_connection'
C:/Ruby27-x64/lib/ruby/gems/2.7.0/gems/activerecord-6.1.4/lib/active_record/connection_adapters/abstract/connection_pool.rb:882:in `public_send'
C:/Ruby27-x64/lib/ruby/gems/2.7.0/gems/activerecord-6.1.4/lib/active_record/connection_adapters/abstract/connection_pool.rb:882:in `new_connection'
C:/Ruby27-x64/lib/ruby/gems/2.7.0/gems/activerecord-6.1.4/lib/active_record/connection_adapters/abstract/connection_pool.rb:926:in `checkout_new_connection'
C:/Ruby27-x64/lib/ruby/gems/2.7.0/gems/activerecord-6.1.4/lib/active_record/connection_adapters/abstract/connection_pool.rb:905:in `try_to_checkout_new_connection'
C:/Ruby27-x64/lib/ruby/gems/2.7.0/gems/activerecord-6.1.4/lib/active_record/connection_adapters/abstract/connection_pool.rb:866:in `acquire_connection'
C:/Ruby27-x64/lib/ruby/gems/2.7.0/gems/activerecord-6.1.4/lib/active_record/connection_adapters/abstract/connection_pool.rb:588:in `checkout'
C:/Ruby27-x64/lib/ruby/gems/2.7.0/gems/activerecord-6.1.4/lib/active_record/connection_adapters/abstract/connection_pool.rb:428:in `connection'
C:/Ruby27-x64/lib/ruby/gems/2.7.0/gems/activerecord-6.1.4/lib/active_record/connection_adapters/abstract/connection_pool.rb:1128:in `retrieve_connection'
C:/Ruby27-x64/lib/ruby/gems/2.7.0/gems/activerecord-6.1.4/lib/active_record/connection_handling.rb:327:in `retrieve_connection'
C:/Ruby27-x64/lib/ruby/gems/2.7.0/gems/activerecord-6.1.4/lib/active_record/connection_handling.rb:283:in `connection'
C:/Ruby27-x64/lib/ruby/gems/2.7.0/gems/activerecord-6.1.4/lib/active_record/tasks/database_tasks.rb:237:in `migrate'
C:/Ruby27-x64/lib/ruby/gems/2.7.0/gems/activerecord-6.1.4/lib/active_record/railties/databases.rake:92:in `block (3 levels) in <main>'
C:/Ruby27-x64/lib/ruby/gems/2.7.0/gems/activerecord-6.1.4/lib/active_record/railties/databases.rake:90:in `each'
C:/Ruby27-x64/lib/ruby/gems/2.7.0/gems/activerecord-6.1.4/lib/active_record/railties/databases.rake:90:in `block (2 levels) in <main>'
C:/Ruby27-x64/lib/ruby/gems/2.7.0/gems/rake-13.0.6/lib/rake/task.rb:281:in `block in execute'
C:/Ruby27-x64/lib/ruby/gems/2.7.0/gems/rake-13.0.6/lib/rake/task.rb:281:in `each'
C:/Ruby27-x64/lib/ruby/gems/2.7.0/gems/rake-13.0.6/lib/rake/task.rb:281:in `execute'
C:/Ruby27-x64/lib/ruby/gems/2.7.0/gems/rake-13.0.6/lib/rake/task.rb:219:in `block in invoke_with_call_chain'
C:/Ruby27-x64/lib/ruby/gems/2.7.0/gems/rake-13.0.6/lib/rake/task.rb:199:in `synchronize'
C:/Ruby27-x64/lib/ruby/gems/2.7.0/gems/rake-13.0.6/lib/rake/task.rb:199:in `invoke_with_call_chain'
C:/Ruby27-x64/lib/ruby/gems/2.7.0/gems/rake-13.0.6/lib/rake/task.rb:188:in `invoke'
C:/Ruby27-x64/lib/ruby/gems/2.7.0/gems/rake-13.0.6/lib/rake/application.rb:160:in `invoke_task'
C:/Ruby27-x64/lib/ruby/gems/2.7.0/gems/rake-13.0.6/lib/rake/application.rb:116:in `block (2 levels) in top_level'
C:/Ruby27-x64/lib/ruby/gems/2.7.0/gems/rake-13.0.6/lib/rake/application.rb:116:in `each'
C:/Ruby27-x64/lib/ruby/gems/2.7.0/gems/rake-13.0.6/lib/rake/application.rb:116:in `block in top_level'
C:/Ruby27-x64/lib/ruby/gems/2.7.0/gems/rake-13.0.6/lib/rake/application.rb:125:in `run_with_threads'
C:/Ruby27-x64/lib/ruby/gems/2.7.0/gems/rake-13.0.6/lib/rake/application.rb:110:in `top_level'
C:/Ruby27-x64/lib/ruby/gems/2.7.0/gems/railties-6.1.4/lib/rails/commands/rake/rake_command.rb:24:in `block (2 levels) in perform'
C:/Ruby27-x64/lib/ruby/gems/2.7.0/gems/rake-13.0.6/lib/rake/application.rb:186:in `standard_exception_handling'
C:/Ruby27-x64/lib/ruby/gems/2.7.0/gems/railties-6.1.4/lib/rails/commands/rake/rake_command.rb:24:in `block in perform'
C:/Ruby27-x64/lib/ruby/gems/2.7.0/gems/rake-13.0.6/lib/rake/rake_module.rb:59:in `with_application'
C:/Ruby27-x64/lib/ruby/gems/2.7.0/gems/railties-6.1.4/lib/rails/commands/rake/rake_command.rb:18:in `perform'
C:/Ruby27-x64/lib/ruby/gems/2.7.0/gems/railties-6.1.4/lib/rails/command.rb:50:in `invoke'
C:/Ruby27-x64/lib/ruby/gems/2.7.0/gems/railties-6.1.4/lib/rails/commands.rb:18:in `<main>'
C:/Ruby27-x64/lib/ruby/gems/2.7.0/gems/bootsnap-1.7.5/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `require'
C:/Ruby27-x64/lib/ruby/gems/2.7.0/gems/bootsnap-1.7.5/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `block in require_with_bootsnap_lfi'
C:/Ruby27-x64/lib/ruby/gems/2.7.0/gems/bootsnap-1.7.5/lib/bootsnap/load_path_cache/loaded_features_index.rb:92:in `register'
C:/Ruby27-x64/lib/ruby/gems/2.7.0/gems/bootsnap-1.7.5/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in `require_with_bootsnap_lfi'
C:/Ruby27-x64/lib/ruby/gems/2.7.0/gems/bootsnap-1.7.5/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:31:in `require'
bin/rails:4:in `<main>'
Caused by:
PG::ConnectionBad: FATALE: autenticazione con password fallita per l'utente "Blog"
C:/Ruby27-x64/lib/ruby/gems/2.7.0/gems/pg-1.2.3-x64-mingw32/lib/pg.rb:58:in `initialize'
C:/Ruby27-x64/lib/ruby/gems/2.7.0/gems/pg-1.2.3-x64-mingw32/lib/pg.rb:58:in `new'
C:/Ruby27-x64/lib/ruby/gems/2.7.0/gems/pg-1.2.3-x64-mingw32/lib/pg.rb:58:in `connect'
C:/Ruby27-x64/lib/ruby/gems/2.7.0/gems/activerecord-6.1.4/lib/active_record/connection_adapters/postgresql_adapter.rb:78:in `new_client'
C:/Ruby27-x64/lib/ruby/gems/2.7.0/gems/activerecord-6.1.4/lib/active_record/connection_adapters/postgresql_adapter.rb:37:in `postgresql_connection'
C:/Ruby27-x64/lib/ruby/gems/2.7.0/gems/activerecord-6.1.4/lib/active_record/connection_adapters/abstract/connection_pool.rb:882:in `public_send'
C:/Ruby27-x64/lib/ruby/gems/2.7.0/gems/activerecord-6.1.4/lib/active_record/connection_adapters/abstract/connection_pool.rb:882:in `new_connection'
C:/Ruby27-x64/lib/ruby/gems/2.7.0/gems/activerecord-6.1.4/lib/active_record/connection_adapters/abstract/connection_pool.rb:926:in `checkout_new_connection'
C:/Ruby27-x64/lib/ruby/gems/2.7.0/gems/activerecord-6.1.4/lib/active_record/connection_adapters/abstract/connection_pool.rb:905:in `try_to_checkout_new_connection'
C:/Ruby27-x64/lib/ruby/gems/2.7.0/gems/activerecord-6.1.4/lib/active_record/connection_adapters/abstract/connection_pool.rb:866:in `acquire_connection'
C:/Ruby27-x64/lib/ruby/gems/2.7.0/gems/activerecord-6.1.4/lib/active_record/connection_adapters/abstract/connection_pool.rb:588:in `checkout'
C:/Ruby27-x64/lib/ruby/gems/2.7.0/gems/activerecord-6.1.4/lib/active_record/connection_adapters/abstract/connection_pool.rb:428:in `connection'
C:/Ruby27-x64/lib/ruby/gems/2.7.0/gems/activerecord-6.1.4/lib/active_record/connection_adapters/abstract/connection_pool.rb:1128:in `retrieve_connection'
C:/Ruby27-x64/lib/ruby/gems/2.7.0/gems/activerecord-6.1.4/lib/active_record/connection_handling.rb:327:in `retrieve_connection'
C:/Ruby27-x64/lib/ruby/gems/2.7.0/gems/activerecord-6.1.4/lib/active_record/connection_handling.rb:283:in `connection'
C:/Ruby27-x64/lib/ruby/gems/2.7.0/gems/activerecord-6.1.4/lib/active_record/tasks/database_tasks.rb:237:in `migrate'
C:/Ruby27-x64/lib/ruby/gems/2.7.0/gems/activerecord-6.1.4/lib/active_record/railties/databases.rake:92:in `block (3 levels) in <main>'
C:/Ruby27-x64/lib/ruby/gems/2.7.0/gems/activerecord-6.1.4/lib/active_record/railties/databases.rake:90:in `each'
C:/Ruby27-x64/lib/ruby/gems/2.7.0/gems/activerecord-6.1.4/lib/active_record/railties/databases.rake:90:in `block (2 levels) in <main>'
C:/Ruby27-x64/lib/ruby/gems/2.7.0/gems/rake-13.0.6/lib/rake/task.rb:281:in `block in execute'
C:/Ruby27-x64/lib/ruby/gems/2.7.0/gems/rake-13.0.6/lib/rake/task.rb:281:in `each'
C:/Ruby27-x64/lib/ruby/gems/2.7.0/gems/rake-13.0.6/lib/rake/task.rb:281:in `execute'
C:/Ruby27-x64/lib/ruby/gems/2.7.0/gems/rake-13.0.6/lib/rake/task.rb:219:in `block in invoke_with_call_chain'
C:/Ruby27-x64/lib/ruby/gems/2.7.0/gems/rake-13.0.6/lib/rake/task.rb:199:in `synchronize'
C:/Ruby27-x64/lib/ruby/gems/2.7.0/gems/rake-13.0.6/lib/rake/task.rb:199:in `invoke_with_call_chain'
C:/Ruby27-x64/lib/ruby/gems/2.7.0/gems/rake-13.0.6/lib/rake/task.rb:188:in `invoke'
C:/Ruby27-x64/lib/ruby/gems/2.7.0/gems/rake-13.0.6/lib/rake/application.rb:160:in `invoke_task'
C:/Ruby27-x64/lib/ruby/gems/2.7.0/gems/rake-13.0.6/lib/rake/application.rb:116:in `block (2 levels) in top_level'
C:/Ruby27-x64/lib/ruby/gems/2.7.0/gems/rake-13.0.6/lib/rake/application.rb:116:in `each'
C:/Ruby27-x64/lib/ruby/gems/2.7.0/gems/rake-13.0.6/lib/rake/application.rb:116:in `block in top_level'
C:/Ruby27-x64/lib/ruby/gems/2.7.0/gems/rake-13.0.6/lib/rake/application.rb:125:in `run_with_threads'
C:/Ruby27-x64/lib/ruby/gems/2.7.0/gems/rake-13.0.6/lib/rake/application.rb:110:in `top_level'
C:/Ruby27-x64/lib/ruby/gems/2.7.0/gems/railties-6.1.4/lib/rails/commands/rake/rake_command.rb:24:in `block (2 levels) in perform'
C:/Ruby27-x64/lib/ruby/gems/2.7.0/gems/rake-13.0.6/lib/rake/application.rb:186:in `standard_exception_handling'
C:/Ruby27-x64/lib/ruby/gems/2.7.0/gems/railties-6.1.4/lib/rails/commands/rake/rake_command.rb:24:in `block in perform'
C:/Ruby27-x64/lib/ruby/gems/2.7.0/gems/rake-13.0.6/lib/rake/rake_module.rb:59:in `with_application'
C:/Ruby27-x64/lib/ruby/gems/2.7.0/gems/railties-6.1.4/lib/rails/commands/rake/rake_command.rb:18:in `perform'
C:/Ruby27-x64/lib/ruby/gems/2.7.0/gems/railties-6.1.4/lib/rails/command.rb:50:in `invoke'
C:/Ruby27-x64/lib/ruby/gems/2.7.0/gems/railties-6.1.4/lib/rails/commands.rb:18:in `<main>'
C:/Ruby27-x64/lib/ruby/gems/2.7.0/gems/bootsnap-1.7.5/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `require'
C:/Ruby27-x64/lib/ruby/gems/2.7.0/gems/bootsnap-1.7.5/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `block in require_with_bootsnap_lfi'
C:/Ruby27-x64/lib/ruby/gems/2.7.0/gems/bootsnap-1.7.5/lib/bootsnap/load_path_cache/loaded_features_index.rb:92:in `register'
C:/Ruby27-x64/lib/ruby/gems/2.7.0/gems/bootsnap-1.7.5/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in `require_with_bootsnap_lfi'
C:/Ruby27-x64/lib/ruby/gems/2.7.0/gems/bootsnap-1.7.5/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:31:in `require'
bin/rails:4:in `<main>'
Tasks: TOP => db:migrate**
HOW CAN I RESOLVE THIS? I'M NEW IN RAILS AND I'M TRYING TO LEARN IT BUT NOW I'M STUCK
So, your database configuration is correctly being used as your error message mentions the username that it attempted to authenticate with. I don't think there's anything wrong with your database config in Rails, I think the problem may be with a mismatch on your Postgres config.
I would try to attempt to connect to the database with the Postgres CLI client or whatever GUI database client you prefer. Use the same credentials as you have in your Rails config and see if you can get the same error.
How did you create this user in your Postgres database? If you have the SQL statement that may be handy to provide for more detail.
Running rails db:create might be the first command to run to ensure that there's nothing associated with the migration that could complicate things. I would expect that you would get the same error message for that command.
Also, what Rails environment are you using for this command? (development or production for example). Note that the production database config uses the env var BLOG_DATABASE_PASSWORD that may not be set in your shell when you run the rails command. The easiest way to test this in one command is:
$ BLOG_DATABASE_PASSWORD=Giungla rails db:migrate
Of course, you would want your production database password to be different to your development database, this is just an example.
I hope something here helps you solve it!
Login to the Postgresql Database,
psql
alter role blog with password 'secret';

Cannot connect rails and mysql2

So I'm trying to perform a simple database dump from the command prompt for the first time and the rails command keeps aborting with an error. This is running Ruby 2.3.0 with rails 5.0.7 and mysql 0.5.0.
C:\Users\MR_ra\Documents\Sites\matt_radin_cms>rails db:schema:dump --trace
** Invoke db:schema:dump (first_time)
** Invoke environment (first_time)
** Execute environment
** Invoke db:load_config (first_time)
** Execute db:load_config
** Execute db:schema:dump
rails aborted!
NameError: uninitialized constant Mysql2::Client::REMEMBER_OPTIONS
C:/Ruby23/lib/ruby/gems/2.3.0/gems/mysql2-0.5.0-x86-mingw32/lib/mysql2/client.rb:14:in `default_query_options'
C:/Ruby23/lib/ruby/gems/2.3.0/gems/mysql2-0.5.0-x86-mingw32/lib/mysql2/client.rb:25:in `initialize'
C:/Ruby23/lib/ruby/gems/2.3.0/gems/activerecord-5.0.7/lib/active_record/connection_adapters/mysql2_adapter.rb:25:in `new'
C:/Ruby23/lib/ruby/gems/2.3.0/gems/activerecord-5.0.7/lib/active_record/connection_adapters/mysql2_adapter.rb:25:in `mysql2_connection'
C:/Ruby23/lib/ruby/gems/2.3.0/gems/activerecord-5.0.7/lib/active_record/connection_adapters/abstract/connection_pool.rb:729:in `new_connection'
C:/Ruby23/lib/ruby/gems/2.3.0/gems/activerecord-5.0.7/lib/active_record/connection_adapters/abstract/connection_pool.rb:773:in `checkout_new_connection'
C:/Ruby23/lib/ruby/gems/2.3.0/gems/activerecord-5.0.7/lib/active_record/connection_adapters/abstract/connection_pool.rb:752:in `try_to_checkout_new_connection'
C:/Ruby23/lib/ruby/gems/2.3.0/gems/activerecord-5.0.7/lib/active_record/connection_adapters/abstract/connection_pool.rb:713:in `acquire_connection'
C:/Ruby23/lib/ruby/gems/2.3.0/gems/activerecord-5.0.7/lib/active_record/connection_adapters/abstract/connection_pool.rb:490:in `checkout'
C:/Ruby23/lib/ruby/gems/2.3.0/gems/activerecord-5.0.7/lib/active_record/connection_adapters/abstract/connection_pool.rb:364:in `connection'
C:/Ruby23/lib/ruby/gems/2.3.0/gems/activerecord-5.0.7/lib/active_record/connection_adapters/abstract/connection_pool.rb:883:in `retrieve_connection'
C:/Ruby23/lib/ruby/gems/2.3.0/gems/activerecord-5.0.7/lib/active_record/connection_handling.rb:128:in `retrieve_connection'
C:/Ruby23/lib/ruby/gems/2.3.0/gems/activerecord-5.0.7/lib/active_record/connection_handling.rb:91:in `connection'
C:/Ruby23/lib/ruby/gems/2.3.0/gems/activerecord-5.0.7/lib/active_record/railties/databases.rake:241:in `block (4 levels) in <top (required)>'
C:/Ruby23/lib/ruby/gems/2.3.0/gems/activerecord-5.0.7/lib/active_record/railties/databases.rake:240:in `open'
C:/Ruby23/lib/ruby/gems/2.3.0/gems/activerecord-5.0.7/lib/active_record/railties/databases.rake:240:in `block (3 levels) in <top (required)>'
C:/Ruby23/lib/ruby/gems/2.3.0/gems/rake-12.3.1/lib/rake/task.rb:271:in `block in execute'
C:/Ruby23/lib/ruby/gems/2.3.0/gems/rake-12.3.1/lib/rake/task.rb:271:in `each'
C:/Ruby23/lib/ruby/gems/2.3.0/gems/rake-12.3.1/lib/rake/task.rb:271:in `execute'
C:/Ruby23/lib/ruby/gems/2.3.0/gems/rake-12.3.1/lib/rake/task.rb:213:in `block in invoke_with_call_chain'
C:/Ruby23/lib/ruby/2.3.0/monitor.rb:214:in `mon_synchronize'
C:/Ruby23/lib/ruby/gems/2.3.0/gems/rake-12.3.1/lib/rake/task.rb:193:in `invoke_with_call_chain'
C:/Ruby23/lib/ruby/gems/2.3.0/gems/rake-12.3.1/lib/rake/task.rb:182:in `invoke'
C:/Ruby23/lib/ruby/gems/2.3.0/gems/rake-12.3.1/lib/rake/application.rb:160:in `invoke_task'
C:/Ruby23/lib/ruby/gems/2.3.0/gems/rake-12.3.1/lib/rake/application.rb:116:in `block (2 levels) in top_level'
C:/Ruby23/lib/ruby/gems/2.3.0/gems/rake-12.3.1/lib/rake/application.rb:116:in `each'
C:/Ruby23/lib/ruby/gems/2.3.0/gems/rake-12.3.1/lib/rake/application.rb:116:in `block in top_level'
C:/Ruby23/lib/ruby/gems/2.3.0/gems/rake-12.3.1/lib/rake/application.rb:125:in `run_with_threads'
C:/Ruby23/lib/ruby/gems/2.3.0/gems/rake-12.3.1/lib/rake/application.rb:110:in `top_level'
C:/Ruby23/lib/ruby/gems/2.3.0/gems/railties-5.0.7/lib/rails/commands/rake_proxy.rb:14:in `block in run_rake_task'
C:/Ruby23/lib/ruby/gems/2.3.0/gems/rake-12.3.1/lib/rake/application.rb:186:in `standard_exception_handling'
C:/Ruby23/lib/ruby/gems/2.3.0/gems/railties-5.0.7/lib/rails/commands/rake_proxy.rb:11:in `run_rake_task'
C:/Ruby23/lib/ruby/gems/2.3.0/gems/railties-5.0.7/lib/rails/commands/commands_tasks.rb:51:in `run_command!'
C:/Ruby23/lib/ruby/gems/2.3.0/gems/railties-5.0.7/lib/rails/commands.rb:18:in `<top (required)>'
bin/rails:4:in `require'
bin/rails:4:in `<main>'
Tasks: TOP => db:schema:dump
It's looking like no Mysql installed in your machine or adapter setting is wrong.
First install mysql server in your machine.
after that install mysql2 gem by below command or adding in application gemfile
gem install mysql2
gem 'mysql2'
then do below setting for your adapter
default: &default
adapter: mysql2
username: xxxxx
password: xxxxx
host: localhost
pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>
timeout: 5000
Hope this will help you out.
I think the problem with mysql2 gem version, you can define the version like this
gem 'mysql2', '~> 0.3.17'
then bundle install, it solved the problem on my hand.
The database.yml
default: &default
adapter: mysql2
host: localhost
encoding: unicode
username: root
password: #=> if you use password to your local databse then use otherwise empty this
pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>
development:
<<: *default
database: database_development

rake test:prepare fails with Rails 4.0.8

I was testing my app (with rspec) when I noticed rake test:prepare throws an odd FATAL: database "postgres" does not exist error. Stranger still, my tests run just fine regardless.
However, whenever I use rake test:prepare --trace (after using rake db:migrate) I get this error and receive the same error when attempting rake db:create RAILS_ENV=test and also rake db:drop RAILS_ENV=test as well. Any idea what I may be overlooking?
Here is the error in question:
** Invoke test:prepare (first_time)
** Invoke db:test:prepare (first_time)
** Invoke environment (first_time)
** Execute environment
** Invoke db:load_config (first_time)
** Execute db:load_config
** Execute db:test:prepare
** Invoke db:test:load (first_time)
** Invoke db:test:purge (first_time)
** Invoke environment
** Invoke db:load_config
** Execute db:test:purge
rake aborted!
PG::Error: FATAL: database "postgres" does not exist
/Users/Wilhelm/.rvm/gems/ruby-2.0.0-p481#rails_4_0/gems/activerecord-4.0.8/lib/active_record/connection_adapters/postgresql_adapter.rb:855:in `initialize'
/Users/Wilhelm/.rvm/gems/ruby-2.0.0-p481#rails_4_0/gems/activerecord-4.0.8/lib/active_record/connection_adapters/postgresql_adapter.rb:855:in `new'
/Users/Wilhelm/.rvm/gems/ruby-2.0.0-p481#rails_4_0/gems/activerecord-4.0.8/lib/active_record/connection_adapters/postgresql_adapter.rb:855:in `connect'
/Users/Wilhelm/.rvm/gems/ruby-2.0.0-p481#rails_4_0/gems/activerecord-4.0.8/lib/active_record/connection_adapters/postgresql_adapter.rb:556:in `initialize'
/Users/Wilhelm/.rvm/gems/ruby-2.0.0-p481#rails_4_0/gems/activerecord-4.0.8/lib/active_record/connection_adapters/postgresql_adapter.rb:41:in `new'
/Users/Wilhelm/.rvm/gems/ruby-2.0.0-p481#rails_4_0/gems/activerecord-4.0.8/lib/active_record/connection_adapters/postgresql_adapter.rb:41:in `postgresql_connection'
/Users/Wilhelm/.rvm/gems/ruby-2.0.0-p481#rails_4_0/gems/activerecord-4.0.8/lib/active_record/connection_adapters/abstract/connection_pool.rb:440:in `new_connection'
/Users/Wilhelm/.rvm/gems/ruby-2.0.0-p481#rails_4_0/gems/activerecord-4.0.8/lib/active_record/connection_adapters/abstract/connection_pool.rb:450:in `checkout_new_connection'
/Users/Wilhelm/.rvm/gems/ruby-2.0.0-p481#rails_4_0/gems/activerecord-4.0.8/lib/active_record/connection_adapters/abstract/connection_pool.rb:421:in `acquire_connection'
/Users/Wilhelm/.rvm/gems/ruby-2.0.0-p481#rails_4_0/gems/activerecord-4.0.8/lib/active_record/connection_adapters/abstract/connection_pool.rb:356:in `block in checkout'
/Users/Wilhelm/.rvm/rubies/ruby-2.0.0-p481/lib/ruby/2.0.0/monitor.rb:211:in `mon_synchronize'
/Users/Wilhelm/.rvm/gems/ruby-2.0.0-p481#rails_4_0/gems/activerecord-4.0.8/lib/active_record/connection_adapters/abstract/connection_pool.rb:355:in `checkout'
/Users/Wilhelm/.rvm/gems/ruby-2.0.0-p481#rails_4_0/gems/activerecord-4.0.8/lib/active_record/connection_adapters/abstract/connection_pool.rb:265:in `block in connection'
/Users/Wilhelm/.rvm/rubies/ruby-2.0.0-p481/lib/ruby/2.0.0/monitor.rb:211:in `mon_synchronize'
/Users/Wilhelm/.rvm/gems/ruby-2.0.0-p481#rails_4_0/gems/activerecord-4.0.8/lib/active_record/connection_adapters/abstract/connection_pool.rb:264:in `connection'
/Users/Wilhelm/.rvm/gems/ruby-2.0.0-p481#rails_4_0/gems/activerecord-4.0.8/lib/active_record/connection_adapters/abstract/connection_pool.rb:546:in `retrieve_connection'
/Users/Wilhelm/.rvm/gems/ruby-2.0.0-p481#rails_4_0/gems/activerecord-4.0.8/lib/active_record/connection_handling.rb:79:in `retrieve_connection'
/Users/Wilhelm/.rvm/gems/ruby-2.0.0-p481#rails_4_0/gems/activerecord-4.0.8/lib/active_record/connection_handling.rb:53:in `connection'
/Users/Wilhelm/.rvm/gems/ruby-2.0.0-p481#rails_4_0/gems/activerecord-4.0.8/lib/active_record/tasks/postgresql_database_tasks.rb:8:in `connection'
/Users/Wilhelm/.rvm/gems/ruby-2.0.0-p481#rails_4_0/gems/activerecord-4.0.8/lib/active_record/tasks/postgresql_database_tasks.rb:30:in `drop'
/Users/Wilhelm/.rvm/gems/ruby-2.0.0-p481#rails_4_0/gems/activerecord-4.0.8/lib/active_record/tasks/postgresql_database_tasks.rb:43:in `purge'
/Users/Wilhelm/.rvm/gems/ruby-2.0.0-p481#rails_4_0/gems/activerecord-4.0.8/lib/active_record/tasks/database_tasks.rb:137:in `purge'
/Users/Wilhelm/.rvm/gems/ruby-2.0.0-p481#rails_4_0/gems/activerecord-4.0.8/lib/active_record/railties/databases.rake:365:in `block (3 levels) in <top (required)>'
/Users/Wilhelm/.rvm/gems/ruby-2.0.0-p481#rails_4_0/gems/rake-10.3.2/lib/rake/task.rb:240:in `call'
/Users/Wilhelm/.rvm/gems/ruby-2.0.0-p481#rails_4_0/gems/rake-10.3.2/lib/rake/task.rb:240:in `block in execute'
/Users/Wilhelm/.rvm/gems/ruby-2.0.0-p481#rails_4_0/gems/rake-10.3.2/lib/rake/task.rb:235:in `each'
/Users/Wilhelm/.rvm/gems/ruby-2.0.0-p481#rails_4_0/gems/rake-10.3.2/lib/rake/task.rb:235:in `execute'
/Users/Wilhelm/.rvm/gems/ruby-2.0.0-p481#rails_4_0/gems/rake-10.3.2/lib/rake/task.rb:179:in `block in invoke_with_call_chain'
/Users/Wilhelm/.rvm/rubies/ruby-2.0.0-p481/lib/ruby/2.0.0/monitor.rb:211:in `mon_synchronize'
/Users/Wilhelm/.rvm/gems/ruby-2.0.0-p481#rails_4_0/gems/rake-10.3.2/lib/rake/task.rb:172:in `invoke_with_call_chain'
/Users/Wilhelm/.rvm/gems/ruby-2.0.0-p481#rails_4_0/gems/rake-10.3.2/lib/rake/task.rb:201:in `block in invoke_prerequisites'
/Users/Wilhelm/.rvm/gems/ruby-2.0.0-p481#rails_4_0/gems/rake-10.3.2/lib/rake/task.rb:199:in `each'
/Users/Wilhelm/.rvm/gems/ruby-2.0.0-p481#rails_4_0/gems/rake-10.3.2/lib/rake/task.rb:199:in `invoke_prerequisites'
/Users/Wilhelm/.rvm/gems/ruby-2.0.0-p481#rails_4_0/gems/rake-10.3.2/lib/rake/task.rb:178:in `block in invoke_with_call_chain'
/Users/Wilhelm/.rvm/rubies/ruby-2.0.0-p481/lib/ruby/2.0.0/monitor.rb:211:in `mon_synchronize'
/Users/Wilhelm/.rvm/gems/ruby-2.0.0-p481#rails_4_0/gems/rake-10.3.2/lib/rake/task.rb:172:in `invoke_with_call_chain'
/Users/Wilhelm/.rvm/gems/ruby-2.0.0-p481#rails_4_0/gems/rake-10.3.2/lib/rake/task.rb:165:in `invoke'
/Users/Wilhelm/.rvm/gems/ruby-2.0.0-p481#rails_4_0/gems/activerecord-4.0.8/lib/active_record/railties/databases.rake:371:in `block (3 levels) in <top (required)>'
/Users/Wilhelm/.rvm/gems/ruby-2.0.0-p481#rails_4_0/gems/rake-10.3.2/lib/rake/task.rb:240:in `call'
/Users/Wilhelm/.rvm/gems/ruby-2.0.0-p481#rails_4_0/gems/rake-10.3.2/lib/rake/task.rb:240:in `block in execute'
/Users/Wilhelm/.rvm/gems/ruby-2.0.0-p481#rails_4_0/gems/rake-10.3.2/lib/rake/task.rb:235:in `each'
/Users/Wilhelm/.rvm/gems/ruby-2.0.0-p481#rails_4_0/gems/rake-10.3.2/lib/rake/task.rb:235:in `execute'
/Users/Wilhelm/.rvm/gems/ruby-2.0.0-p481#rails_4_0/gems/rake-10.3.2/lib/rake/task.rb:179:in `block in invoke_with_call_chain'
/Users/Wilhelm/.rvm/rubies/ruby-2.0.0-p481/lib/ruby/2.0.0/monitor.rb:211:in `mon_synchronize'
/Users/Wilhelm/.rvm/gems/ruby-2.0.0-p481#rails_4_0/gems/rake-10.3.2/lib/rake/task.rb:172:in `invoke_with_call_chain'
/Users/Wilhelm/.rvm/gems/ruby-2.0.0-p481#rails_4_0/gems/rake-10.3.2/lib/rake/task.rb:201:in `block in invoke_prerequisites'
/Users/Wilhelm/.rvm/gems/ruby-2.0.0-p481#rails_4_0/gems/rake-10.3.2/lib/rake/task.rb:199:in `each'
/Users/Wilhelm/.rvm/gems/ruby-2.0.0-p481#rails_4_0/gems/rake-10.3.2/lib/rake/task.rb:199:in `invoke_prerequisites'
/Users/Wilhelm/.rvm/gems/ruby-2.0.0-p481#rails_4_0/gems/rake-10.3.2/lib/rake/task.rb:178:in `block in invoke_with_call_chain'
/Users/Wilhelm/.rvm/rubies/ruby-2.0.0-p481/lib/ruby/2.0.0/monitor.rb:211:in `mon_synchronize'
/Users/Wilhelm/.rvm/gems/ruby-2.0.0-p481#rails_4_0/gems/rake-10.3.2/lib/rake/task.rb:172:in `invoke_with_call_chain'
/Users/Wilhelm/.rvm/gems/ruby-2.0.0-p481#rails_4_0/gems/rake-10.3.2/lib/rake/task.rb:165:in `invoke'
/Users/Wilhelm/.rvm/gems/ruby-2.0.0-p481#rails_4_0/gems/rake-10.3.2/lib/rake/application.rb:150:in `invoke_task'
/Users/Wilhelm/.rvm/gems/ruby-2.0.0-p481#rails_4_0/gems/rake-10.3.2/lib/rake/application.rb:106:in `block (2 levels) in top_level'
/Users/Wilhelm/.rvm/gems/ruby-2.0.0-p481#rails_4_0/gems/rake-10.3.2/lib/rake/application.rb:106:in `each'
/Users/Wilhelm/.rvm/gems/ruby-2.0.0-p481#rails_4_0/gems/rake-10.3.2/lib/rake/application.rb:106:in `block in top_level'
/Users/Wilhelm/.rvm/gems/ruby-2.0.0-p481#rails_4_0/gems/rake-10.3.2/lib/rake/application.rb:115:in `run_with_threads'
/Users/Wilhelm/.rvm/gems/ruby-2.0.0-p481#rails_4_0/gems/rake-10.3.2/lib/rake/application.rb:100:in `top_level'
/Users/Wilhelm/.rvm/gems/ruby-2.0.0-p481#rails_4_0/gems/rake-10.3.2/lib/rake/application.rb:78:in `block in run'
/Users/Wilhelm/.rvm/gems/ruby-2.0.0-p481#rails_4_0/gems/rake-10.3.2/lib/rake/application.rb:176:in `standard_exception_handling'
/Users/Wilhelm/.rvm/gems/ruby-2.0.0-p481#rails_4_0/gems/rake-10.3.2/lib/rake/application.rb:75:in `run'
/Users/Wilhelm/.rvm/gems/ruby-2.0.0-p481#rails_4_0/gems/rake-10.3.2/bin/rake:33:in `<top (required)>'
/Users/Wilhelm/.rvm/gems/ruby-2.0.0-p481#rails_4_0/bin/rake:23:in `load'
/Users/Wilhelm/.rvm/gems/ruby-2.0.0-p481#rails_4_0/bin/rake:23:in `<main>'
/Users/Wilhelm/.rvm/gems/ruby-2.0.0-p481#rails_4_0/bin/ruby_executable_hooks:15:in `eval'
/Users/Wilhelm/.rvm/gems/ruby-2.0.0-p481#rails_4_0/bin/ruby_executable_hooks:15:in `<main>'
Tasks: TOP => db:test:load => db:test:purge
Here is what my test environment looks like (according to my gemfile):
gem 'rails', '4.0.8'
gem 'pg', '0.15.1'
group :development, :test do
gem 'rspec-rails', '2.13.1'
end
group :test do
gem 'selenium-webdriver', '2.35.1'
gem 'capybara', '2.1.0'
end
Edit
Here is what my database.yml file looks like :
development:
adapter: postgresql
endoding: unicode
database: myapp_development
pool: 5
timeout: 5000
hostname: localhost
test:
adapter: postgresql
endoding: unicode
database: myapp_test
pool: 5
timeout: 5000
hostname: localhost
production:
adapter: postgresql
database: myapp_production
pool: 5
timeout: 5000
Try using a Postgres client(pgAdmin3 for example, or psql on the command line) to attempt to create a database named 'postgres' on your server. Don't try using Rails rake tasks to do this - they will probably fail for the same reason.
Using psql you could try:
CREATE DATABASE postgres;
or use pgAdmin3 (free with Postgres) if you prefer a GUI.
You will need to be logged in as a user with the appropriate privileges for creating databases.
As I understand it, this database is created automatically by newer versions of Postgres. It needs no tables. Your instance of Postgres may not have it or it may have been deleted or renamed, but the database adapter used by Rails needs it to be there for some reason.

Why is Rake aborting because of "Bad file Descriptor"?

I have a problem creating a database using rake db:create.
I followed the "Fat Free CRM Guides: Installation on Microsoft Windows" guide to install the Fat Free CRM on Windows.
I am on 32-bit Windows 7. Rake is 0.8.7. RubyGems is 2.0.3 and Ruby is 1.9.3. I am using MySQL2 v0.2.6.
The error I got was:
C:\RailsInstaller\fat_free_crm>rake db:create RAILS_ENV=production --trace
** Invoke db:create (first_time)
** Invoke db:load_config (first_time)
** Execute db:load_config
** Invoke rails_env (first_time)
** Execute rails_env
** Execute db:create
rake aborted!
Bad file descriptor
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/mysql2-0.2.6-x86-mingw32/lib/active_record/connection_adapters/mysql2_adapter.rb:312:in `query'
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/mysql2-0.2.6-x86-mingw32/lib/active_record/connection_adapters/mysql2_adapter.rb:312:in `execute'
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/mysql2-0.2.6-x86-mingw32/lib/active_record/connection_adapters/mysql2_adapter.rb:629:in `configure_connecti
on'
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/mysql2-0.2.6-x86-mingw32/lib/active_record/connection_adapters/mysql2_adapter.rb:169:in `initialize'
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/mysql2-0.2.6-x86-mingw32/lib/active_record/connection_adapters/mysql2_adapter.rb:16:in `new'
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/mysql2-0.2.6-x86-mingw32/lib/active_record/connection_adapters/mysql2_adapter.rb:16:in `mysql2_connection'
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/activerecord-3.2.13/lib/active_record/connection_adapters/abstract/connection_pool.rb:315:in `new_connectio
n'
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/activerecord-3.2.13/lib/active_record/connection_adapters/abstract/connection_pool.rb:325:in `checkout_new_
connection'
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/activerecord-3.2.13/lib/active_record/connection_adapters/abstract/connection_pool.rb:247:in `block (2 leve
ls) in checkout'
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/activerecord-3.2.13/lib/active_record/connection_adapters/abstract/connection_pool.rb:242:in `loop'
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/activerecord-3.2.13/lib/active_record/connection_adapters/abstract/connection_pool.rb:242:in `block in chec
kout'
C:/RailsInstaller/Ruby1.9.3/lib/ruby/1.9.1/monitor.rb:211:in `mon_synchronize'
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/activerecord-3.2.13/lib/active_record/connection_adapters/abstract/connection_pool.rb:239:in `checkout'
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/activerecord-3.2.13/lib/active_record/connection_adapters/abstract/connection_pool.rb:102:in `block in conn
ection'
C:/RailsInstaller/Ruby1.9.3/lib/ruby/1.9.1/monitor.rb:211:in `mon_synchronize'
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/activerecord-3.2.13/lib/active_record/connection_adapters/abstract/connection_pool.rb:101:in `connection'
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/activerecord-3.2.13/lib/active_record/connection_adapters/abstract/connection_pool.rb:410:in `retrieve_conn
ection'
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/activerecord-3.2.13/lib/active_record/connection_adapters/abstract/connection_specification.rb:171:in `retr
ieve_connection'
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/activerecord-3.2.13/lib/active_record/connection_adapters/abstract/connection_specification.rb:145:in `conn
ection'
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/activerecord-3.2.13/lib/active_record/railties/databases.rake:120:in `rescue in create_database'
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/activerecord-3.2.13/lib/active_record/railties/databases.rake:85:in `create_database'
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/activerecord-3.2.13/lib/active_record/railties/databases.rake:62:in `block (3 levels) in <top (required)>'
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/activerecord-3.2.13/lib/active_record/railties/databases.rake:62:in `each'
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/activerecord-3.2.13/lib/active_record/railties/databases.rake:62:in `block (2 levels) in <top (required)>'
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/rake-10.0.4/lib/rake/task.rb:246:in `call'
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/rake-10.0.4/lib/rake/task.rb:246:in `block in execute'
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/rake-10.0.4/lib/rake/task.rb:241:in `each'
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/rake-10.0.4/lib/rake/task.rb:241:in `execute'
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/rake-10.0.4/lib/rake/task.rb:184:in `block in invoke_with_call_chain'
C:/RailsInstaller/Ruby1.9.3/lib/ruby/1.9.1/monitor.rb:211:in `mon_synchronize'
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/rake-10.0.4/lib/rake/task.rb:177:in `invoke_with_call_chain'
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/rake-10.0.4/lib/rake/task.rb:170:in `invoke'
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/rake-10.0.4/lib/rake/application.rb:143:in `invoke_task'
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/rake-10.0.4/lib/rake/application.rb:101:in `block (2 levels) in top_level'
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/rake-10.0.4/lib/rake/application.rb:101:in `each'
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/rake-10.0.4/lib/rake/application.rb:101:in `block in top_level'
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/rake-10.0.4/lib/rake/applic....
C:/RailsInstaller/Ruby1.9.3/bin/rake:23:in `load'
C:/RailsInstaller/Ruby1.9.3/bin/rake:23:in `<main>'
Tasks: TOP => db:create
C:\RailsInstaller\fat_free_crm>[/code]
I changed libmysql.dll for win7 - 32bit
The configuration of database.yml is:
development:
adapter: mysql2
encoding: utf8
database: fat_free_crm_development
pool: 5
username: root
password: ale
#socket: /var/run/mysqld/mysqld.sock
host: localhost
#host: 127.0.0.1
port: 3306
test:
#<<: *development
database: fat_free_crm_test
production:
#<<: *development
adapter: mysql2
encoding: utf8
#database: crm_production
database: fat_free_crm_production
pool: 5
username: root
password: ale
#socket: /tmp/mysql.sock
#host: 127.0.0.1
host: localhost
port: 3306
staging:
#<<: *development
database: fat_free_crm_staging
Does anyone have any ideas?
At lines 9, 25, 29, 43 remove &development and <<*development. I think you have syntax errors in your database.yml file.

Rails rake aborted! can't convert Hash into String

Ok i had this working and i'm not sure what i could have changed to make rake db:create not working now. I ran rake db:drop to drop my db so i can start from scratch and now rake db:create is having a problem.
Here's my stacktrace below. I'm not sure how to go about troubleshooting this.
$ rake db:create --trace
** Invoke db:create (first_time)
** Invoke db:load_config (first_time)
** Invoke rails_env (first_time)
** Execute rails_env
** Execute db:load_config
** Execute db:create
rake aborted!
can't convert Hash into String
/Users/TomCaflisch/.rvm/gems/ruby-1.9.3-p327#famnfo/gems/mysql2-0.3.11/lib/mysql2/client.rb:44:in `connect'
/Users/TomCaflisch/.rvm/gems/ruby-1.9.3-p327#famnfo/gems/mysql2-0.3.11/lib/mysql2/client.rb:44:in `initialize'
/Users/TomCaflisch/.rvm/gems/ruby-1.9.3-p327#famnfo/gems/activerecord-3.1.8/lib/active_record/connection_adapters/mysql2_adapter.rb:17:in `new'
/Users/TomCaflisch/.rvm/gems/ruby-1.9.3-p327#famnfo/gems/activerecord-3.1.8/lib/active_record/connection_adapters/mysql2_adapter.rb:17:in `mysql2_connection'
/Users/TomCaflisch/.rvm/gems/ruby-1.9.3-p327#famnfo/gems/activerecord-3.1.8/lib/active_record/connection_adapters/abstract/connection_pool.rb:304:in `new_connection'
/Users/TomCaflisch/.rvm/gems/ruby-1.9.3-p327#famnfo/gems/activerecord-3.1.8/lib/active_record/connection_adapters/abstract/connection_pool.rb:323:in `checkout_new_connection'
/Users/TomCaflisch/.rvm/gems/ruby-1.9.3-p327#famnfo/gems/activerecord-3.1.8/lib/active_record/connection_adapters/abstract/connection_pool.rb:265:in `block (2 levels) in checkout'
/Users/TomCaflisch/.rvm/gems/ruby-1.9.3-p327#famnfo/gems/activerecord-3.1.8/lib/active_record/connection_adapters/abstract/connection_pool.rb:261:in `loop'
/Users/TomCaflisch/.rvm/gems/ruby-1.9.3-p327#famnfo/gems/activerecord-3.1.8/lib/active_record/connection_adapters/abstract/connection_pool.rb:261:in `block in checkout'
/Users/TomCaflisch/.rvm/rubies/ruby-1.9.3-p327/lib/ruby/1.9.1/monitor.rb:211:in `mon_synchronize'
/Users/TomCaflisch/.rvm/gems/ruby-1.9.3-p327#famnfo/gems/activerecord-3.1.8/lib/active_record/connection_adapters/abstract/connection_pool.rb:260:in `checkout'
/Users/TomCaflisch/.rvm/gems/ruby-1.9.3-p327#famnfo/gems/activerecord-3.1.8/lib/active_record/connection_adapters/abstract/connection_pool.rb:162:in `connection'
/Users/TomCaflisch/.rvm/gems/ruby-1.9.3-p327#famnfo/gems/activerecord-3.1.8/lib/active_record/connection_adapters/abstract/connection_pool.rb:409:in `retrieve_connection'
/Users/TomCaflisch/.rvm/gems/ruby-1.9.3-p327#famnfo/gems/activerecord-3.1.8/lib/active_record/connection_adapters/abstract/connection_specification.rb:115:in `retrieve_connection'
/Users/TomCaflisch/.rvm/gems/ruby-1.9.3-p327#famnfo/gems/activerecord-3.1.8/lib/active_record/connection_adapters/abstract/connection_specification.rb:89:in `connection'
/Users/TomCaflisch/.rvm/gems/ruby-1.9.3-p327#famnfo/gems/activerecord-3.1.8/lib/active_record/railties/databases.rake:86:in `rescue in create_database'
/Users/TomCaflisch/.rvm/gems/ruby-1.9.3-p327#famnfo/gems/activerecord-3.1.8/lib/active_record/railties/databases.rake:54:in `create_database'
/Users/TomCaflisch/.rvm/gems/ruby-1.9.3-p327#famnfo/gems/activerecord-3.1.8/lib/active_record/railties/databases.rake:42:in `block (2 levels) in <top (required)>'
/Users/TomCaflisch/.rvm/gems/ruby-1.9.3-p327#famnfo/gems/rake-10.0.2/lib/rake/task.rb:227:in `call'
/Users/TomCaflisch/.rvm/gems/ruby-1.9.3-p327#famnfo/gems/rake-10.0.2/lib/rake/task.rb:227:in `block in execute'
/Users/TomCaflisch/.rvm/gems/ruby-1.9.3-p327#famnfo/gems/rake-10.0.2/lib/rake/task.rb:222:in `each'
/Users/TomCaflisch/.rvm/gems/ruby-1.9.3-p327#famnfo/gems/rake-10.0.2/lib/rake/task.rb:222:in `execute'
/Users/TomCaflisch/.rvm/gems/ruby-1.9.3-p327#famnfo/gems/rake-10.0.2/lib/rake/task.rb:166:in `block in invoke_with_call_chain'
/Users/TomCaflisch/.rvm/rubies/ruby-1.9.3-p327/lib/ruby/1.9.1/monitor.rb:211:in `mon_synchronize'
/Users/TomCaflisch/.rvm/gems/ruby-1.9.3-p327#famnfo/gems/rake-10.0.2/lib/rake/task.rb:159:in `invoke_with_call_chain'
/Users/TomCaflisch/.rvm/gems/ruby-1.9.3-p327#famnfo/gems/rake-10.0.2/lib/rake/task.rb:152:in `invoke'
/Users/TomCaflisch/.rvm/gems/ruby-1.9.3-p327#famnfo/gems/rake-10.0.2/lib/rake/application.rb:141:in `invoke_task'
/Users/TomCaflisch/.rvm/gems/ruby-1.9.3-p327#famnfo/gems/rake-10.0.2/lib/rake/application.rb:99:in `block (2 levels) in top_level'
/Users/TomCaflisch/.rvm/gems/ruby-1.9.3-p327#famnfo/gems/rake-10.0.2/lib/rake/application.rb:99:in `each'
/Users/TomCaflisch/.rvm/gems/ruby-1.9.3-p327#famnfo/gems/rake-10.0.2/lib/rake/application.rb:99:in `block in top_level'
/Users/TomCaflisch/.rvm/gems/ruby-1.9.3-p327#famnfo/gems/rake-10.0.2/lib/rake/application.rb:108:in `run_with_threads'
/Users/TomCaflisch/.rvm/gems/ruby-1.9.3-p327#famnfo/gems/rake-10.0.2/lib/rake/application.rb:93:in `top_level'
/Users/TomCaflisch/.rvm/gems/ruby-1.9.3-p327#famnfo/gems/rake-10.0.2/lib/rake/application.rb:71:in `block in run'
/Users/TomCaflisch/.rvm/gems/ruby-1.9.3-p327#famnfo/gems/rake-10.0.2/lib/rake/application.rb:158:in `standard_exception_handling'
/Users/TomCaflisch/.rvm/gems/ruby-1.9.3-p327#famnfo/gems/rake-10.0.2/lib/rake/application.rb:68:in `run'
/Users/TomCaflisch/.rvm/gems/ruby-1.9.3-p327#famnfo/gems/rake-10.0.2/bin/rake:37:in `<top (required)>'
/Users/TomCaflisch/.rvm/gems/ruby-1.9.3-p327#famnfo/bin/rake:19:in `load'
/Users/TomCaflisch/.rvm/gems/ruby-1.9.3-p327#famnfo/bin/rake:19:in `<main>'
/Users/TomCaflisch/.rvm/gems/ruby-1.9.3-p327#famnfo/bin/ruby_noexec_wrapper:14:in `eval'
/Users/TomCaflisch/.rvm/gems/ruby-1.9.3-p327#famnfo/bin/ruby_noexec_wrapper:14:in `<main>'
Tasks: TOP => db:create
database.yml
# SQLite version 3.x
# gem install sqlite3
#
# Ensure the SQLite 3 gem is defined in your Gemfile
# gem 'sqlite3'
development:
adapter: mysql2
encoding: utf8
database: FamNFo_development
# local
username: root
password:
# server
# username: famnfo_dev
# password: Panther89!1
# local
socket: /tmp/mysql.sock
# server
# socket: /var/lib/mysql/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: mysql2
encoding: utf8
database: FamNFo_test
# local
# username: root
# password:
# server
username: root
password:
# local
socket: /tmp/mysql.sock
# server
#socket: /var/lib/mysql/mysql.sock
production:
adapter: mysql2
encoding: utf8
database: FamNFo_production
# local
# username: root
# password:
# server
username: myusername
password: mypassword
# local
# socket: /tmp/mysql.sock
# server
socket: /var/lib/mysql/mysql.sock
When you have extra leading spaces before a key in your YAML file it is interpreted as a sub-key, and thus the upper key is interpreted as a hash instead of a string. So removing the extra space before socket in the test section should fix the problem.

Resources