Your cart
  • IMG
    {{cart_item.name}}
    {{cart_item.variation_attribute_name}}: {{cart_item.variation_attribute_label}}
    {{cart_item.item_unit}}: {{ setCurrency(cart_item.price)}}
    {{ setCurrency(cart_item.price*cart_item.quantity)}}
    Invalid quantity more than stock
Total :
{{setCurrency(cart.sub_total)}}

There is no item in the cart. If you want to buy, Please click here.

Installing PostgreSQL in Ubuntu 20.04

Complete guide to start Linux OS and install essential applications in Linux

Created by :
Linux
tutorial
Programming, Software and application
1408
2022-01-09 18:30:29

PostgreSQL is a powerful, open source object-relational database system with over 30 years of active development that has earned it a strong reputation for reliability, feature robustness, and performance.


Installing PostgreSQL in Ubuntu 20.04

Log into your Ubuntu system and update the system software packages using the following apt command.

sudo apt update


Now install the latest version of PostgreSQL from the default Ubuntu repositories.

 

installing the Postgres package along with a -contrib package that adds some additional utilities and functionality:

sudo apt install postgresql postgresql-contrib


During the installation, the installer will create a new PostgreSQL cluster (a collection of databases that will be managed by a single server instance), thus initializing the database. The default data directory is /var/lib/postgresql/12/main and the configurations files are stored in the /etc/postgresql/12/main directory.


After PostgreSQL installed, you can confirm that the PostgreSQL service is active, running and is enabled under systemd using the following systemctl commands:

sudo systemctl is-active postgresql
sudo systemctl is-enabled postgresql
sudo systemctl status postgresql

Also, confirm that the Postgresql server is ready to accept connections from clients as follows:

sudo pg_isready


Using PostgreSQL Databases

The installation procedure created a user account called postgres that is associated with the default Postgres role. There are a few ways to utilize this account to access Postgres. One way is to switch over to the postgres account on your server by running the following command:


sudo -i -u postgres

 

Then you can access the Postgres prompt by running:


psql

 

This will log you into the PostgreSQL prompt, and from here you are free to interact with the database management system right away.


To exit out of the PostgreSQL prompt, run the following:


\q

 

This will bring you back to the postgres Linux command prompt. To return to your regular system user, run the exit command:


exit

 

Another way to connect to the Postgres prompt is to run the psql command as the postgres account directly with sudo:


sudo -u postgres psql

 

This will log you directly into Postgres without the intermediary bash shell in between.


Again, you can exit the interactive Postgres session by running the following:


\q


To check psql client version:

psql -V

this output as like


postgres@saidul-Inspiron-5502:~$ psql -V
psql (PostgreSQL) 12.9 (Ubuntu 12.9-0ubuntu0.20.04.1)


Thanks