Create a PostgreSQL Server Using AWS EC2
  • Introduction
  • AWS EC2: Launching Instance
    • Overview
    • Create Security Group
    • Create Launch Template
    • Option 1: Create Auto Scaling Group
    • Option 2: Create a Single Instance
    • Attach Elastic IP Address
  • Ubuntu 20.04: Configuring PostgreSQL
    • Overview
    • Install PostgreSQL
    • Add Role to PostgreSQL Server
    • Allow Remote Connection
  • Remote Server: Accessing Server on Local Computer
    • Overview
    • Connect with pgAdmin4
    • Connect with Python API
  • AWS EC2: Backup Server
    • Overview
    • Configuring Automatic Backups
  • Next Steps
Powered by GitBook
On this page

Was this helpful?

  1. Ubuntu 20.04: Configuring PostgreSQL

Add Role to PostgreSQL Server

Add role to login and create databases in your postgres server

PreviousInstall PostgreSQLNextAllow Remote Connection

Last updated 4 years ago

Was this helpful?

To start using PostgreSQL, we will need a user and a database.

First, we'll switch to the postgres user account on our instance.

sudo su postgres

To run PostgresSQL, type

psql

In the next two lines, we'll create a user role who will be able to login and create databases (). Replace username and 'password' with your own:

CREATE ROLE username 
WITH SUPERUSER CREATEDB CREATEROLE LOGIN ENCRYPTED PASSWORD 'password';

To stop running PostgresSQL, type

\q

To log out of the postgres account, type

exit
3