WikiGalaxy

Personalize

Install PostgreSQL on Windows

Download the Installer:

Visit the official PostgreSQL website and download the Windows installer. Ensure you choose the correct version for your system architecture (32-bit or 64-bit).

Run the Installer:

Launch the downloaded installer file. Follow the on-screen instructions to proceed with the installation.

Choose Installation Directory:

Select the directory where you want PostgreSQL to be installed. The default location is usually sufficient.

Set Password for PostgreSQL Superuser:

During installation, you'll be prompted to set a password for the PostgreSQL superuser (postgres). Remember this password as you'll need it later.


      // Example command to connect to PostgreSQL
      psql -U postgres -h localhost
    

Complete Installation:

Finish the installation by clicking 'Next' and 'Finish' as prompted. Optionally, install additional components like pgAdmin.

Verify Installation:

Open the command prompt and type psql --version to verify the installation. It should display the installed PostgreSQL version.

Console Output:

psql (PostgreSQL) 13.3

Install PostgreSQL on macOS

Use Homebrew:

Homebrew is a popular package manager for macOS. Install it if you haven't already, then use it to install PostgreSQL.

Install PostgreSQL:

Open Terminal and run the command brew install postgresql to install PostgreSQL.

Start PostgreSQL Service:

After installation, start the PostgreSQL service using brew services start postgresql.

Verify Installation:

Check the installation by executing psql --version in the terminal.


      // Starting PostgreSQL service
      brew services start postgresql
    

Connect to PostgreSQL:

Use the command psql postgres to connect to the PostgreSQL database.

Console Output:

Server started successfully

Install PostgreSQL on Ubuntu

Update Package List:

Before installing, update your package list to ensure you have the latest information. Use the command sudo apt update.

Install PostgreSQL:

Run sudo apt install postgresql postgresql-contrib to install PostgreSQL and additional utilities.

Check PostgreSQL Status:

Verify that PostgreSQL is running by checking its status using sudo systemctl status postgresql.

Access PostgreSQL:

Switch to the postgres user with sudo -i -u postgres and access the PostgreSQL shell using psql.


      // Command to check PostgreSQL status
      sudo systemctl status postgresql
    

Exit PostgreSQL Shell:

Type \q to exit the PostgreSQL shell once you're done.

Console Output:

Active: active (running)

Install PostgreSQL on CentOS

Enable PostgreSQL Repository:

Ensure you have the PostgreSQL repository enabled. Use sudo yum install -y https://download.postgresql.org/pub/repos/yum/reporpms/EL-$(rpm -E %rhel)-x86_64/pgdg-redhat-repo-latest.noarch.rpm.

Install PostgreSQL:

Install PostgreSQL using sudo yum install -y postgresql13-server.

Initialize Database:

Initialize the database using sudo /usr/pgsql-13/bin/postgresql-13-setup initdb.

Start PostgreSQL Service:

Start and enable the PostgreSQL service using sudo systemctl enable --now postgresql-13.


      // Command to start and enable PostgreSQL service
      sudo systemctl enable --now postgresql-13
    

Verify Installation:

Check the PostgreSQL version to verify the installation using psql --version.

Console Output:

PostgreSQL 13.3

Install PostgreSQL using Docker

Install Docker:

Ensure Docker is installed on your system. Follow the official Docker installation guide if needed.

Pull PostgreSQL Image:

Pull the latest PostgreSQL image from Docker Hub using docker pull postgres.

Run PostgreSQL Container:

Run a PostgreSQL container using docker run --name my-postgres -e POSTGRES_PASSWORD=mysecretpassword -d postgres.

Access PostgreSQL:

Access the PostgreSQL instance using docker exec -it my-postgres psql -U postgres.


      // Command to run PostgreSQL container
      docker run --name my-postgres -e POSTGRES_PASSWORD=mysecretpassword -d postgres
    

Stop and Remove Container:

To stop and remove the container, use docker stop my-postgres followed by docker rm my-postgres.

Console Output:

PostgreSQL database system is ready to accept connections

Install PostgreSQL on Debian

Add PostgreSQL Repository:

Add the PostgreSQL repository to your system using 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 Repository Signing Key:

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

Install PostgreSQL:

Update the package list and install PostgreSQL using sudo apt update && sudo apt install postgresql.

Start PostgreSQL:

Start the PostgreSQL service using sudo systemctl start postgresql.


      // Command to start PostgreSQL service
      sudo systemctl start postgresql
    

Enable PostgreSQL on Boot:

Enable PostgreSQL to start on boot using sudo systemctl enable postgresql.

Console Output:

PostgreSQL started successfully

Install PostgreSQL on Fedora

Enable PostgreSQL Module:

Enable the PostgreSQL module using sudo dnf module enable postgresql:13.

Install PostgreSQL:

Install PostgreSQL using sudo dnf install postgresql-server.

Initialize Database:

Initialize the database using sudo postgresql-setup --initdb.

Start PostgreSQL Service:

Start and enable the PostgreSQL service with sudo systemctl enable --now postgresql.


      // Command to initialize database
      sudo postgresql-setup --initdb
    

Check PostgreSQL Status:

Verify the service status using sudo systemctl status postgresql.

Console Output:

Active: active (running)

Install PostgreSQL on Arch Linux

Update System:

Ensure your system is up to date using sudo pacman -Syu.

Install PostgreSQL:

Install PostgreSQL using sudo pacman -S postgresql.

Initialize Database:

Initialize the database cluster with sudo -iu postgres initdb -D /var/lib/postgres/data.

Start PostgreSQL:

Start the PostgreSQL service using sudo systemctl start postgresql.


      // Command to initialize database cluster
      sudo -iu postgres initdb -D /var/lib/postgres/data
    

Enable PostgreSQL on Boot:

Enable PostgreSQL to start on boot using sudo systemctl enable postgresql.

Console Output:

PostgreSQL started successfully

Install PostgreSQL on FreeBSD

Update Ports Tree:

Ensure your ports tree is up to date using portsnap fetch update.

Install PostgreSQL:

Navigate to the PostgreSQL port directory and install using cd /usr/ports/databases/postgresql13-server && make install clean.

Initialize Database:

Initialize the database using service postgresql initdb.

Start PostgreSQL Service:

Start the PostgreSQL service with service postgresql start.


      // Command to start PostgreSQL service
      service postgresql start
    

Enable PostgreSQL on Boot:

Add PostgreSQL to the system startup using echo 'postgresql_enable="YES"' >> /etc/rc.conf.

Console Output:

PostgreSQL service started successfully

logo of wikigalaxy

Newsletter

Subscribe to our newsletter for weekly updates and promotions.

Privacy Policy

 • 

Terms of Service

Copyright © WikiGalaxy 2025