Install PostgreSQL

== Installing PostgreSQL on Different Operating Systems ==

windows

Step 1: Download and Install the Package

Download PGAdmin and PostgreSQL installation packages suitable for Windows from PostgreSQL official website.

Step 2: Install PGAdmin

In the downloaded folder, run setup.exe and select "PGAdmin".

Step 3: Install PostgreSQL

In the downloaded folder, run setup.exe and select "PostgreSQL".

linux

Step 1: Add Trusted Source

sudo gpg --keyserver keyserver.ubuntu.com --recv-keys 4F27/B8A6

Step 2: Install PostgreSQL

sudo apt-get install postgresql-13

macOS

Step 1: Install PostgreSQL Using Homebrew

brew install postgres

Step 2: Create and Start the PostgreSQL Service

createdb mydatabase
pg_ctl start -D /var/pgsql/db/13/default

Step 3: Connect to the PostgreSQL Service

psql -U postgres

Linux (Ubuntu)

Step 1: Install Dependencies

sudo apt-get install build-essential libpq-dev libxml2-dev libcurl4-openssl-dev zlib1g-dev

Step 2: Download and Compile PostgreSQL Source Code

wget https://github.com/postgresql/postgres/archive/v13.3.tar.gz
tar xvf v13.3.tar.gz
cd v13.3
./configure --prefix=/usr/local/pgsql --with-openssl=/usr/local/ssl
make all

Step 3: Install PostgreSQL

sudo make install

Step 4: Restart the PostgreSQL Service

sudo service postgresql restart