PostgreSQL installation Guide

Fardeen Khan
Code Panthers

--

A bit about PostgreSQL from the official docs

PostgreSQL is a powerful, open-source object-relational database system that uses and extends the SQL language combined with many features that safely store and scale the most complicated data workloads. The origins of PostgreSQL date back to 1986 as part of the POSTGRES project at the University of California at Berkeley and has more than 35 years of active development on the core platform.

In this article, we are covering instructions to install the PostgreSQL database on your local System running Linux/Windows/Mac Operating Systems

Linux Installation

For Debian Distros

Run the following commands

# 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'

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

# Update the package lists:
sudo apt-get update

# Install the latest version of PostgreSQL.
# If you want a specific version, use 'postgresql-12' or similar instead of 'postgresql':
sudo apt-get -y install postgresql

For more details, click here

For RPM Distros

Run the following commands for installation

# Install the repository RPM:
sudo yum install -y https://download.postgresql.org/pub/repos/yum/reporpms/EL-6-x86_64/pgdg-redhat-repo-latest.noarch.rpm

# Install PostgreSQL:
sudo yum install -y postgresql15-server

# Optionally initialize the database and enable automatic start:
sudo service postgresql-15 initdb
sudo chkconfig postgresql-15 on
sudo service postgresql-15 start

Use dnf if using RHEL 8+ or Fedora

Run the below commands for activation, post-installation

  postgresql-setup --initdb
systemctl enable postgresql.service
systemctl start postgresql.service

For more details visit here

Windows Installation

  • Download the installer
  • Pick the latest stable version for Windows x86_64 (15.2 at the time of writing this article)
  • Use the default installation directory C:\Program Files\PostgreSQL\15 if you have admin access or change to another path
  • For components, you can select all other than Stack Builder which is optional
  • Choose a Data directory where the actual DB files would be stored
  • Choose a strong password for the DB superuser — postgres
  • Leave the default port for the server to 5432
  • Review all the details before installation
  • Start the installation and sit back. This may take a few minutes
  • Run pgAdmin to verify that the DB is installed properly

macOS Installation

  1. Download the installer for v15.2 here
  2. Follow the same instructions as Windows and continue with the installations

Well, that’s it. I hope you were able to use this as a go-to template for installing PostgreSQL Database on Windows/Linux/macOS

Thank you for dropping by!!

Support me by sponsoring a coffee here https://www.buymeacoffee.com/fardeen9983

--

--