11.2. Setting up the database

Rails applications are almost always used with a database. For local development use the PostgreSQL database.

Procedure

  1. Install the database:

    $ sudo yum install -y postgresql postgresql-server postgresql-devel
  2. Initialize the database:

    $ sudo postgresql-setup initdb

    This command creates the /var/lib/pgsql/data directory, in which the data is stored.

  3. Start the database:

    $ sudo systemctl start postgresql.service
  4. When the database is running, create your rails user:

    $ sudo -u postgres createuser -s rails

    Note that the user created has no password.