Skip to main content

Creating a new Postgres User, Database

Updated 1 min readMarkdown
Part of seriesSnippets

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;

192 views

About the author

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

No comments yet. Be the first to comment.

More from this blog