autoconnect89 autoconnect89 - 4 months ago 26
MySQL Question

Ruby-On-Rails Database Setup Using Mysql

I am having a problem on ruby on rails during database installation following the tutorial from http://www.tutorialspoint.com/ruby-on-rails/rails-active-records.htm

First, I created a new project using the code below,

C:\projects>rails new libray


It created the project successfully. I followed the database installation using mysql then changed the database.yml content.

From code (Original value from fresh created project)

default: &default
adapter: sqlite3
pool: 5
timeout: 5000

development:
<<: *default
database: db/development.sqlite3

# 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:
<<: *default
database: db/test.sqlite3

production:
<<: *default
database: db/production.sqlite3


To new code:

development:
adapter: mysql
database: library_development
username: root
password: 1234
host: localhost

test:
adapter: mysql
database: library_test
username: root
password: 1234
host: localhost

production:
adapter: mysql
database: library_production
username: root
password: 1234
host: localhost


Next is to create active records using the code:

C:\projects>library>rails generate model book


But I got the following error.

Click to see error in img

I am new to Ruby on Rails, any help is greatly appreciated.

Answer

The problem is that You were right in your configuration but you used only mysql in adapter it should be adapter: mysql2 instead