Selman ALPDÜNDAR

How to create user and grant permission to user in PostgreSQL

For create database use below in your terminal.

CREATE DATABASE test2; 

Not: do not forget semicolon  if you do not put semicolon your code will not work.

For create user name and password use below in your terminal.

CREATE USER test2 WITH PASSWORD '123456';

Not: do not forget semicolon  if you do not put semicolon your code will not work.

For grant permission to user use below in your terminal.

GRANT ALL ON DATABASE test2 TO test2;

Not: do not forget semicolon  if you do not put semicolon your code will not work.

first test2 is Database name  and second test2  is user name please do not forget to change those for you. If everything is okey you will see like below input and output in your terminal.

 



Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.