← Volver al blog

How to Install PostgreSQL on Ubuntu

  • Xernode
  • 1 min de lectura
  • 11 de abril de 2026
Database ubuntu vps database postgresql sql

Introduction

PostgreSQL is a powerful open-source relational database system. This guide shows you how to install PostgreSQL on your Ubuntu VPS.

Step-by-step Guide

  1. Update your package list
    • sudo apt update
  2. Install PostgreSQL
    • sudo apt install -y postgresql postgresql-contrib
  3. Check PostgreSQL service status
    • sudo systemctl status postgresql
  4. Switch to the postgres user
    • sudo -i -u postgres
  5. Access the PostgreSQL shell
    • psql
  6. (Optional) Create a new database and user
    • CREATE DATABASE mydb;
    • CREATE USER myuser WITH ENCRYPTED PASSWORD 'mypassword';
    • GRANT ALL PRIVILEGES ON DATABASE mydb TO myuser;
    • \q
    • exit
  7. (Optional) Enable remote access
    • Edit postgresql.conf and pg_hba.conf as needed, then restart PostgreSQL:n
      • sudo systemctl restart postgresql

Recommendations

  • Use strong passwords for all database users.
  • Regularly back up your databases.
  • Keep PostgreSQL updated for security and performance.

Call To Action

eed a VPS for your PostgreSQL databases? Check out our hosting plans: https://xernode.com/#pricing

Related Guides