In this section of PostgreSQL, we will install PostgreSQL Version 14 on Ubuntu 18.04.4 LTS (Bionic Beaver) system. Once the PostgreSQL installation is complete, we will explore PostgreSQL with examples.
- Operating System (OS). We have used the Ubuntu 18.04.4 LTS version Linux operating system for this installation.
- Hardware Requirements.The minimum hardware requirement is a 1 GHz processor, 2 GB of RAM, and 512 MB of HDD.
- PostgreSQL. The PostgreSQL Version 14 has been used to install on Linux.
Installation Steps of PostgreSQL Version 14 on Ubuntu 18.04.4 LTS
Step 1. The First Step in PostgreSQL installation on Ubuntu Linux is to enable the apt repository. Please go to the https://www.postgresql.org/download/linux/ubuntu/ directory for Ubuntu and copy the apt repository line. Run the following statement to enable the PostgreSQL apt repository for Ubuntu.
cloudduggu@ubuntu:-$ sudo sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list'
Step 2. In this step use the below command for importing the repository signing key and updating the package lists.
cloudduggu@ubuntu:-$ wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -
Step 3. The PostgreSQL official repository for Ubuntu has been added to our Linux system, now use the below command to update the system repository list.
cloudduggu@ubuntu:-$ sudo apt-get update
Step 4. Now use the apt-get command as mentioned below to install PostgreSQL. We have used 14 with the below command to install the PostgreSQL 14 Version. You can install any version just by mentioning it.
cloudduggu@ubuntu:-$ sudo apt-get -y install postgresql-14
Step 5. Once the PostgreSQL Installation is complete the cluster is initialized by default. We can use the below command to check the status of the PostgreSQL Cluster.
cloudduggu@ubuntu:-$ ps -ef | grep postgres
Step 6. PostgreSQL creates the username postgres and system account with the same name during the installation time, We can use this user to login into PostgreSQL. Use the below command to log in, and supply your user's password to authenticate. Once the login is complete, use the psql tool to connect to the cluster as mentioned in the below command.
cloudduggu@ubuntu:-$ sudo -i -u postgres