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;

Ryan Sukale

Ryan is just a regular guy next door trying to manage his life and finances.

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *