## Creating a Database
* Using mysql, here are 4 commands when working with databases:
* `SHOW DATABASES;`
* `CREATE DATABASE db_name;`
* `USE db_name;`
* `DROP DATABASE db_name;`
* **DON'T FORGET THE `;`!**
* Start up mysql server: `mysql.server start`
* then run `mysql -u root -p`, enter password
* `CREATE DATABASE name_development`
* Then `USE name_development` to run commands against that db
* Bad to use `root` user in mysql, create a new user for your app!
* This command will create and grant the user all rights to the DB, after the `USE` db command
```
GRANT ALL PRIVILIGES ON db_name.*
TO 'username'@'localhost'
IDENTIFIED BY 'password';
SHOW GRANTS FOR 'username'@'localhost';
```
* Now you can exit, and sign in as the new user and log in to a specific db:
`mysql -u simple_cms -p simple_cms_development`
* `SHOW TABLES;`
* `SHOW FIELDS FROM USERS;`
* `SELECT * FROM table_name;` is used to show what data is contained in the table.
* When you execute `SHOW TABLES`, you will notice a table called `schema migrations`. It contains
all the migration files from the `db/migrate` folder.
* Now that you have created a database, you have to tell rails to use it!
* In `config/database.yml`:
```yml
development:
adapter: mysql2
encoding: utf8
database: simple_cms_development
pool: 5
username: simple_cms
password: secretpassword
socket: /tmp/mysql.sock
```
* Migrate the database schema into our app: `rake db:schema:dump`, empty schema, connection
successful!
* **YAML = YAML AIN'T MARKUP LANGUAGE**