Configuring Database Connections

The database connection configuration is part of every environment. The configuration file config/database.yml holds the connection information:

  adapter: mysql
  database: rails-db
  username: rails-db-user
  password: rails-db-user-password
  socket: /var/run/mysqld/mysqld.sock

You can adjust the entries according to your needs. We strongly advise against using the same database for more than one environment.

The following commands can be used to create a MySQL database:

$ mysql -u root -p
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 275
Server version: 5.0.37 MySQL Community Server (GPL)

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

mysql> create database Rails-DB;
Query OK, 1 row affected (0.00 sec)

mysql> grant all on Rails-DB.* to 'Rails-DB-User'@'localhost' identified by 'Rails-DB-User-Password';
Query OK, 0 rows affected (0.00 sec)

mysql> exit