Installing Database
This guide explains how to install PostgreSQL 15.4 on Linux using the PostgreSQL APT repository.
Update and Install Prerequisites
Open your terminal and run the following command to update your system packages and install necessary dependencies.
sudo apt update && sudo apt upgrade -y
sudo apt install -y wget gnupg lsb-releaseAdd PostgreSQL APT Repository
Import the PostgreSQL GPG key
wget -qO - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -Add the PostgreSQL repository to your system:
echo "deb http://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg main" | sudo tee /etc/apt/sources.list.d/pgdg.listInstall PostgreSQL 15.4
Update the package list again to include the PostgreSQL repository
sudo apt updateInstall PostgreSQL 15.4
sudo apt install -y postgresql-15Start and Enable PostgreSQL Service
Start the PostgreSQL service
Enable PostgreSQL to start on boot
Verify the service status
Configure PostgreSQL
Change postgres password in
/etc/postgresql/15/main/pg_hba.conf
Restart the PostgreSQL service after making changes
Install Postgres using the PostgreSQL Official Installer
Download the Installer:
Visit the PostgreSQL official website and download the installer for macOS.
Run the Installer:
Open the
.dmgfile and follow the installation wizard.The wizard will guide you through steps like setting the installation path, password for the
postgresuser, and selecting components.
Start PostgreSQL:
Use the PostgreSQL Application Stack Builder to manage and start the PostgreSQL server.
Verify the Installation:
Post-Installation Steps
Initialize and Start PostgreSQL
If installed with Homebrew:
Initialize the database manually (if not started):
Access PostgreSQL
To enter the PostgreSQL interactive shell:
Create a New User and Database
Create a user:
Create a database:
Grant privileges:
Postgres installing the PostgreSQL Official Installer
Download the Installer:
Visit the PostgreSQL official website.
Click on Windows and download the latest installer.
Run the Installer:
Double-click the downloaded
.exefile to start the setup wizard.
Follow the Installation Steps:
Choose the installation directory (default:
C:\Program Files\PostgreSQL\<version>).Select components (ensure "pgAdmin" is checked for a graphical interface).
Set a password for the default
postgresuser (remember this password).Choose a port (default:
5432).Select the locale (use the default or choose your preferred one).
Complete Installation:
The installer will install PostgreSQL and initialize the database cluster.
Verify Installation:
Post-Installation Steps
Initialize and Start PostgreSQL
If installed with Homebrew:
Initialize the database manually (if not started):
Access PostgreSQL
To enter the PostgreSQL interactive shell:
Create a New User and Database
Create a user:
Create a database:
Grant privileges:
Last updated