Home / Today I Learned / How to Create the Initial Postgresql Database?

How to Create the Initial Postgresql Database?

1 min read
postgresql

How to Install PostgreSQL

You can use brew to install PostgreSQL:

  $ brew install postgresql

Start the process

You can use brew services to manage your processes like this:

  $ brew services start postgresql

Create the initial database

If you try starting the PostgreSQL console (using psql) and get the following error:

  psql: error: could not connect to server: FATAL:  database "user" does not exist

then you need to create the initial database using:

  $ createdb

If your next step is wiring Rails to read replicas or legacy sources, I covered that in How to connect to multiple databases in Ruby on Rails 7.

Share this article: