• 0

Create a user and a database in postgres

Creating users and databases in postgres is pretty simple via the command line. Assuming you already have postgres 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;