Lievcin
Lievcin

Reputation: 938

Error when running rake db:migrate

I'm following the railscast where Ryan sets up a VPS. But I need to install mysql instead of postgresql.

when I run the cap deploy:cold command, it all seems to run fine, until it runs the bundle, which fails when trying to install the mysql2 gem.

so i logged into the server and installed it manually (the database had already been setup).

but when i run the rake db:migrate command I keep getting this error:

rake aborted!
database configuration does not specify adapter

Tasks: TOP => db:migrate => db:load_config

in the database.yml file i have the following

production:
  adapter: mysql2
  encoding: utf8
  reconnect: false
  database: blog_production
  pool: 5
  username: blog
  password: *****
  host: localhost
  socket: /var/run/mysqld/mysqld.sock

I've edited the socket from default, added and removed the host line, and installed the gem manually, but nothing seems to make it work!

Upvotes: 0

Views: 2997

Answers (2)

Kim Miller
Kim Miller

Reputation: 886

Corrupt yml file solved it for me.

Renamed and recreated the database.yml file and it worked.

Upvotes: 2

moritz
moritz

Reputation: 25757

This usually happens when your deployment scripts or the currently logged in user on the VPS have not set the RAILS_ENV environment variable. Then it defaults to 'development' and your database.yml would have no configuration for that environment. So try

RAILS_ENV=production bundle exec rake db:migrate --trace

instead.

Upvotes: 5

Related Questions