PostgreSQL installation on Linux
This is my first blog on PostgreSQL and in this blog we will see and learn how to download and install PostgreSQL on a Linux machine (Ubuntu 20.04).
Most Linux platforms like Ubuntu, Red Hat / CentOS, Debian and SUSE have PostgreSQL integrated with their package management. By default, PostgreSQL is available in all Ubuntu versions as PostgreSql “Snapshot”.
However other versions of the same can be downloaded through the PostgreSQL webpage and select your Linux distribution.
It is recommended that you install PostgreSQL this way since it ensures a proper integration with the operating system including automatic patching and other update management functionality. Now let's see and follow below three steps:
Check for the current version of PostgreSQL on your Ubuntu machine.
Install PostgreSQL
Verify the installation
Check for the current version of PostgreSQL
First we will see on our linux (Ubuntu in my case) machine if PostgreSQL is installed or not? If its installed then we will check the version else we will proceed for PostgreSQL installation.
postgres -V
Download PostgreSQL
Visit PostgreSQL Apt Repository page and follow the steps or script that allows you to install PostgreSQL on your Ubuntu machine.
Installing PostgreSQL on Ubuntu
First, execute the following command to create the file repository configuration:
$ sudo sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list'
Second, import the repository signing key:
$ wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -
Third, update the package list:
$ sudo apt-get update
Finally, install the latest version of PostgreSQL:
$ sudo apt-get -y install postgresql
If you want to install a specific version, you can use postgresql-version instead of postgresql. For example, to install PostgreSQL version 12, you use the following command:
$ sudo apt-get install postgresql-12
It will take few minutes to download and install the PostgreSQL.
Verifying the Installation of PostgreSQL
Now we'll verify the PostgreSQL installation using psql shell. Follow the steps:
1) Open the terminal and run the below command to log into PostgreSQL server:
sudo su postgres
2) Now use the below command to enter the PostgreSQL shell:
psql
3) Now run the below command to check for the PostgreSQL version:
SELECT version();
That's all in this post. If you liked this blog and interested in knowing more about PostgreSQL, Please Like, Follow, Share & Subscribe to www.ImJhaChandan.com .
Kommentare