database configuration does not specify adapter

Viewed 94771

I'm getting this error when I'm trying to connect to a mysql database. The problem is that the application works for weeks, and then randomly I get this message. When I get this error message the application is not able to reconnect to the database until I restart it.

I'm using a configuration file to connect to the database, and the adapter is specified...the database configuration is not generated at runtime.

Do you have any idea on what is going on?

25 Answers

I had this error when I mistakenly started rails server with

sudo rails s -e "Production" -p 80

and I should have started rails with

sudo rails s -e "production" -p 80

I've found a couple of clues that this might be related to older library (ActiveRecord) or gem versions. For example, problems with fixtures even though rest of app seems okay (after an upgrade) or this trac ticket, which "stops gems from requiring an adapter from an old Active Record gem". Both of these are old, though, but it might be worth making sure your gems are up to date (if possible).

Are you using the native rails MySQL adapter by any chance? This is now deprecated under rails, but it's conceivable it's still limping along.

I've taken a very quick look at connection_specification.rb, too, which is where this error is coming from, and my best guess is that a reconnect is failing... but why (since it was obviously okay when you first started the app)? Are you doing something wild like calling ActiveRecord::Base.establish_connection in your application controller (or elsewhere)?

Or perhaps something like: script runner is called from cron in the dead of night when the connection has dropped. Unfortunately, the runner is invoked with an incorrect RAILS_ENV. Thus the wrong stanza is read from database.yml, and that stanza contains an invalid adapter:?

Remember to use the C-Based ruby gem for mysql. The ruby-based is unstable for production.

Try installing the gem

gem install mysql

Remember to copy libmySQL.dll into the ruby bin directory.

Check the spelling of adapter I had adaptor and got this error.

I had this error message when upgrading from Rails 4 to 5. I was calling

establish_connection "myconnection"

where "myconnection" is a valid key in my database.yml. However, passing this parameter as a string is apparently no longer supported. Using a symbol instead got rid of the problem.

Related