Well, it is a common issue for us beginners. This issue comes from the moment when you create your new project in rails. Let’s say to have an example
$ rails new toy –d mysql
- After you do the bundle and start your server, most likely you will have an error. To correct it you need to go to your database.yml and modify the following:
 
Add a password in the password field as shown below, this is the password you use to secure mysql.
default: &default
  adapter: mysql2
  encoding: utf8
  pool: 5
  username: root
  password: mypassword
  socket: /tmp/mysql.sock
Also, comment out the database adding a hash tag (#)before the name as shown below
development:
 : *default
   database: #toy_development
- Then restart your command line and go to the root of your application and type:
 
$ rails s 
You have to see the Ruby on Rails welcome page..
- After,  you need to create a database.
 
Create a DATABASE. 
The issue message is saying that not DATABASE is selected. It is because I didn’t create one. When you work with MySQL you have to create one, so:
- Go to the root of my application and type:
 
$ mysql –u root –p 
$ Passwor: mypassword (Enter your password, this is the one you entered to secure MySQL)
Note: This example works wit a project called toy and the user I wanted to grant privileges is mark and the password I’ll give is 45mark. Below you will see where I apply these elements. Remember to apply your own elements on each part of the statement.
Create and user for this project
- Once you are in, you will see the pointer (mysql> ), so type after it:
 
mysql> GRANT ALL PRIVILEGES ON toy_development.* TO 'mark'@'localhost' IDENTIFIED BY '45mark';
mysql> exit;
- Check that it is working by typing:
 
$ mysql –u mark –p toy_development
Enter password: 45mark (You enter the one you gave)
- Open database.yml file and configure what is needed and fix as required. In my case I will chance the username to mark and the password to 45mark
 
default: &default
  adapter: mysql2
  encoding: utf8
  pool: 5
  username: mark
  password: 45mark
  socket: /tmp/mysql.sock
- Also, REMOVE the hash tag (#) added before
development:
  : *default
     database: toy_development 
Save it.
- Go to the root of the application and type
 
$ rake db:schema:dump
Done!!
I hope this helps. Happy coding!!
Thanks