Step 1 – Install PostgreSQL
Option 1 – Installation From APT Repository
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
sudo -u postgres psql
SELECT version();
Option 2 – Installation Using Local Ubuntu Repository
apt show postgresql
sudo apt install postgresql postgresql-contrib
sudo apt-get update
sudo -u postgres psql
SELECT version();
Step 2 – Connect to PostgreSQL
sudo su postgres
psql
Step 3 – Change User Password
sudo -u postgres psql
ALTER USER postgres PASSWORD 'NewPassw0rd';
\p
sudo service postgresql restart
Creating a User on PostgreSQL
su - postgres
createuser --interactive
sudo -u postgres psql
\du
Creating a Database on PostgreSQL
sudo -u postgres createdb TheNewUser
sudo adduser TheNewUser --force-badname
sudo -u TheNewUser psql
\conninfo
Install pgAdmin
curl -fsSL https://www.pgadmin.org/static/packages_pgadmin_org.pub | sudo gpg --dearmor -o /etc/apt/trusted.gpg.d/pgadmin.gpg
sudo sh -c 'echo "deb https://ftp.postgresql.org/pub/pgadmin/pgadmin4/apt/$(lsb_release -cs) pgadmin4 main" > /etc/apt/sources.list.d/pgadmin4.list'
sudo apt update
sudo apt install pgadmin4
sudo /usr/pgadmin4/bin/setup-web.sh
185.185.185.185/pgadmin4