postgre

enter postgre shell

sudo su - postgres

psql

or

psql -U postgres

check is truly initialized

pg_isready

check systemd service

sudo systemctl status postgresql

change UNIX user postgres password

sudo passwd postgres

Creating user

 sudo -u postgres createuser <username>

Creating Database

sudo -u postgres createdb <dbname>

Giving the user a password

psql

\password <username>;

Granting privileges on database

psql 

grant all privileges on database <dbname> to <username> ;

Grant superuser

ALTER USER myuser WITH SUPERUSER;

Remove superuser status:

ALTER USER username WITH NOSUPERUSER;

List All Databases

\list

check user

psql

\du

More Helpful commands :
https://gist.github.com/Kartones/dd3ff5ec5ea238d4c546


You'll only receive email when they publish something new.

More from Rifky Adni Putra
All posts