0

I am new to RAILS and RUBY. I am trying to create a demo project to practice. When I was trying to configure my mysql database with RAILS, I got following error:

C:\Sites\simple_cms>rake db:schema:dump
rake aborted!
ActiveRecord::AdapterNotSpecified: 'development' database is not configured. 
Available: ["default", "adapter", "pool", "timeout", "database", "username", 
"password", "host"]

Tasks: TOP => db:schema:dump => db:load_config
(See full trace by running task with --trace)

Below is my database.yml file content

# SQLite version 3.x
#   gem install sqlite3
#
#   Ensure the SQLite 3 gem is defined in your Gemfile
#   gem 'sqlite3'
#
  default: &default
  adapter: mysql
  pool: 5
  timeout: 5000
  database: simple_cms_development
  username: dumdum 
  password: dumdum
  host: localhost

development:
  <<: *default  

# 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

I tried searching online but got no clear help. I am running RAILS on WINDOWS 10

3 Answers3

0

before using rake db:schema:dump you have to create the database and then later you create tables,

to create database for your project

rake db:create

to create tables

rake db:migrate

after this you may be can check table schema using rake db:schema:dump

widjajayd
  • 6,090
  • 4
  • 30
  • 41
0

I felt like you didn't indent your yaml file properly and therefore you the development cannot read the settings of default. Please try to indent it properly.

Another thing that I have noticed is that your port number is not set. I have updated the settings as follow by referring to Correct MySQL configuration for Ruby on Rails Database.yml file

Please try the following and let me know:

default: &default
  adapter: mysql2
  timeout: 5000
  username: dumdum 
  password: dumdum
  host: localhost
  port: 3306

development:
  <<: *default
  database: simple_cms_development

# 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: simple_cms_test

production:
  <<: *default
  database: simple_cms_production

Hope this helps.

yihyang
  • 111
  • 1
  • 5
  • 1
    Thanks yihyang. That really helped. There were issues: 1. default: &default indentation was not proper 2. gem file was not configured for mysql2 – Talib Shaikh Jul 29 '17 at 03:28
0

Try below code:

Gemfile

gem 'mysql2'

config/database.yml

default: &default
  adapter: mysql2
  pool: 5
  timeout: 5000
  username: username #your mysql username
  password: password #your mysql password

development:
  <<: *default
  database: simple_cms_development

test:
  <<: *default
  database: simple_cms_test

production:
  <<: *default
  database: simple_cms_production

Then run command:

bundle

rake db:create

rake db:migrate
puneet18
  • 4,341
  • 2
  • 21
  • 27
  • Thanks @puneet18. That really helped. There were issues: 1. default: &default indentation was not proper 2. gem file was not configured for mysql2 – Talib Shaikh Jul 29 '17 at 03:30