Create a user and a database in postgres

Cre­at­ing users and data­bases in post­gres is pretty sim­ple via the com­mand line.
Assum­ing you already have post­gres installed, just do the following.

# Step 1: Login into the psql shell
sudo -u postgres psql

# Step 2: Create a user
CREATE ROLE example_username LOGIN password 'example_password';

# Step 3: (Optional) Make a user an owner while creating a database
CREATE DATABASE example_database ENCODING 'UTF8' OWNER example_username;

Ryan Sukale

Ryan is a UX engineer living in San Francisco, California.

You may also like...