Skip to main content

Command Palette

Search for a command to run...

Creating a new Postgres User, Database

Updated
1 min read
S

Working on mission to provide, Software Engineering Trainings easily and freely accessible to everyone through EdTech

Creating Postgres User, Database easy way

1.  sudo su postgres 
2.  psql
3.  CREATE DATABASE database_name;
4.  CREATE USER my_username WITH PASSWORD 'my_password';
5.  GRANT ALL PRIVILEGES ON DATABASE "database_name" to my_username;

Note: on mac you can psql postgres to enter postgres shell

Note: If you get error `ERROR: permission denied for schema public` on PG>=15 then do

# connect to the newly created database first and then apply grant

\c database_name
GRANT ALL ON SCHEMA public TO my_username;
187 views

More from this blog

S

Shrawan's Blog

10 posts

Working on mission to provide, Software Engineering Trainings easily and freely accessible to everyone through EdTech

~ I write Django related blogs and tutorial at https://djangotherightway.com/