I am absolutely new to Ruby on Rails and I'm following a book that's written as a tutorial, but it is a bit outdated.
When I run the server and browse localhost:3000
something is not working right, I get the following error: ActiveRecord::ConnectionNotEstablished
MySQL is installed in my computer, the databases are created and all of this works in other example applications I have been giving a look to.
This is the databases.yml
file:
development:
adapter: mysql2
database: emporium_development
username: emporium
password: hacked
test:
adapter: mysql2
database: emporium_test
username: emporium
password: hacked
I made sure the mysql2 gem is installed like this: gem install mysql2
Shed some light on me please.
First setup your gems by running
Bundle install
Then your database needs to be created:
rake db:create
If you have some pending migrations (and if you don't this can still be run, it just won't do anything):
rake db:migrate
This should setup a database that works, provided you gave the correct password.
Note that if you already have a database that you want to get rid of, you can run
rake db:drop
and then try to create the database again.
Does any of this solve your problem ?
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.