How to create a user with PostgreSQL?

How to create a user with PostgreSQL? #postgres #database #user

How to create a user with PostgreSQL?
Photo by Myriam Jessier / Unsplash

Here is a quick tutorial for today using Postgresql on Command Line using a terminal in Linux:

sudo -u postgres createuser jammy
sudo -u postgres createdb my_local_db
sudo -u postgres psql (get into command line interface mode)
  1. ALTER USER jammy WITH PASSWORD ‘my_new_shiny_password’;
  2. GRANT ALL PRIVILEGES ON DATABASE my_local_db to jammy

Once you install the Postgres tool, the process should be the same with Windows and  Mac.

You can also use free GUI tools such as:

  1. PGAdmin
  2. HeidiSQL (not cross-platform)  
  3. DBWeaver