Created
October 12, 2020 15:30
-
-
Save anilahir/a7b3908392ff1e8ff507fd6d938cadc3 to your computer and use it in GitHub Desktop.
Revisions
-
anilahir created this gist
Oct 12, 2020 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,42 @@ Installation: ----------------------------------------- ``` sudo sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list' wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add - sudo apt-get update sudo apt-get -y install postgresql ``` Setup User: --------------------------------------------------------- ``` $ sudo -u postgres psql CREATE DATABASE <dbname>; CREATE USER <username> WITH ENCRYPTED PASSWORD '<password>'; GRANT ALL PRIVILEGES ON DATABASE <dbname> TO <username>; ``` Create user: ------------------------------------ ``` sudo -u postgres createuser <username> ``` Create Database ---------------------------------------- ``` sudo -u postgres createdb <dbname> ``` Give password to the user: ---------------------------------------------- ``` $ sudo -u postgres psql psql=# ALTER USER <username> WITH ENCRYPTED PASSWORD '<password>'; ``` Grant privileges on database: ------------------------------------------------ ``` psql=# GRANT ALL PRIVILEGES ON DATABASE <dbname> TO <username>; ```