Installing the PostgreSQL database
PostgreSQL is an open-source database that can be installed on multiple platforms. On Ubuntu, it can be installed using the following commands:
To add the repo to the package list:
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 -q https://www.postgresql.org/media/keys/ACCC4CF8.asc -O - | sudo apt-key add -
To update the package list:
sudo apt-get update
apt-get install postgresql postgresql-contrib
This installs the database on an Ubuntu machine and starts a server on port 5432
. Now, in order to enter the database shell, use these commands. PostgreSQL creates a default user called postgres
to log in. Take a look at the following command:
sudo su - postgres
Now the user has access to the database. Launch the PostgreSQL shell using the psql
command:
psql
This shows that PostgreSQL follows a different approach for entering into the shell compared to other similar databases...