Skip to main content

How to Install PostgreSQL on Ubuntu 18.04

 Introduction

PostgreSQL is an open-source, object-relational database system with a strong reputation for feature robustness, extensibility, and technical standards compliance.

The latest version of this database system is PostgreSQL 12.1, while versions 11.6, 10.11, 9.6.16, 9.5.20, and 9.4.25 still get regular support updates.


PostgreSQL is one of the most famous open-source, freely available database management software systems out there. This system is quick, reliable, flexible, easy to use, and contains advanced features that allow complex applications to be built in a fault-tolerable workspace. There are two different packages of PostgreSQL, each intended for a specific purpose. The PostgreSQL Client package works on the client side to connect to servers, while the PostgreSQL Server package allows your system to set up and host your own databases. This tutorial will show you how to install these two packages and how to set up the PostgreSQL server in a few easy steps.

Install PostgreSQL from PostgreSQL Apt Repository

PostgreSQL is available in all Ubuntu versions by default, but it doesn’t guarantee automatic updates when new releases come out. The local repository only has "snapshots" of a specific version. The best practice is to install the software from the PostgreSQL Apt Repository.

The PostgreSQL Apt Repository provides the latest PostgreSQL version, as well as all previous server packages, extensions, and modules.

Step 1: 

sudo apt-get install wget ca-certificates


Step 2 : 

wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -


Now add the repository to your system.


sudo sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt/ `lsb_release -cs`-pgdg main" >> /etc/apt/sources.list.d/pgdg.list'


After adding the official PostgreSQL repository, make sure to update the package list. Doing this ensures you install the latest PostgreSQL package.


sudo apt-get update

sudo apt-get install postgresql postgresql-contrib



srinivasa@ubuntu:~/Desktop$ sudo su - postgres


From the above steps installation of Postgresql is completed successfully. 






Comments

Popular posts from this blog

PostgreSQL Vacuum and Vacuum full are not two different processes

  PostgreSQL’s   VACUUM   and   VACUUM FULL   are not separate processes but rather different operational modes of the same maintenance command. Here’s why: Core Implementation Both commands share the same underlying codebase and are executed through the  vacuum_rel()  function in PostgreSQL’s source code ( src/backend/commands/vacuum.c ). The key distinction lies in the  FULL  option, which triggers additional steps: Standard  VACUUM : Removes dead tuples (obsolete rows) and marks space reusable  within PostgreSQL Updates the visibility map to optimize future queries Runs concurrently with read/write operations VACUUM FULL : Rewrites the entire table into a new disk file, compressing it and reclaiming space for the  operating system Rebuilds all indexes and requires an  ACCESS EXCLUSIVE  lock, blocking other operations Key Differences in Behavior Aspect Standard VACUUM VACUUM FULL Space Reclamation Internal reuse onl...

Job scheduler for PostgreSQL "pg_cron"

What is pg_cron   : -   pg_cron is a simple cron-based job scheduler for   PostgreSQL (9.5 or higher)   that runs inside the database as an extension. It uses the same syntax as regular cron, but it allows you to schedule PostgreSQL commands directly from the database . Why We need it ? Running periodic maintenance jobs or removing old data is a common requirement in PostgreSQL. A simple way to achieve this is to configure cron or another external daemon to periodically connect to the database and run a command. Let's see how it's works  Step 1 :-  For implementing/Installation of pg_cron you need to download source code from git Dowload link  export PATH=/usr/local/pgsql/bin:$PATH wget https://github.com/citusdata/pg_cron/archive/master.zip unzip master cd pg_cron-master/ make make install    Step 2 : - To start the pg_cron background worker when PostgreSQL starts, you need to add pg_cron to  shared_preload_libraries   in post...

All about pg_hba.conf(authentication methods- Postgresql)

  pg_hba.conf is the PostgreSQL access policy configuration file, which is located in the /var/lib/pgsql/10/data/ directory (PostgreSQL10) by default. The configuration file has 5 parameters, namely: TYPE (host type), DATABASE (database name), USER (user name), ADDRESS (IP address and mask), METHOD (encryption method) host all all 192.168.109.103/22 md5 host dbName user 192.168.109.106/22 trust Modify the server-side pg_hba.conf file Make the shell can connect to the postgres database secretly: Modify the authentication file $PGDATA/pg_hba.conf, add the following lines, and reload to make the configuration take effect immediately. host pankajconnect postgresql 192.168.8.103/32 trust Reload to take effect: pg_ctl reload -D $PGDATA Examples: 1. Allow local login to the database using PGAdmin3, database address  localhost, user user1, database user1db: host user1db user1 127.0.0.1/32 md5 2. Allow 10.1.1.0~10.1.1.255 network segments to log in to the database: host all all 10.1.1....