sudo apt-get install postgresql
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
===
// Confirm installation and get the version number
psql --version
// There are 3 commands you need to know once PostgreSQL is installed:
//status for checking the status of your database.
sudo service postgresql
// start to start running your database.
sudo service postgresql
// stop to stop running your database.
sudo service postgresql
// The default admin user, postgres, needs a password assigned in order to connect to a database.
// To set a password:
// Enter the command:
sudo passwd postgres
// You will get a prompt to enter your new password.
// Close and reopen your terminal.