Install PostgreSQL on Debian

Install PostgreSQL on Debian #

PostgreSQL is an open-source, powerful, and reliable object-relational database system. This guide will show you how to install PostgreSQL on Debian.

Steps to Install PostgreSQL #

  1. Update your system:

    sudo apt-get update
    sudo apt-get upgrade
    
  2. Install PostgreSQL:

    sudo apt-get install postgresql postgresql-contrib
    
  3. Check if PostgreSQL is running:

    sudo systemctl status postgresql
    
  4. Log in to PostgreSQL:

    sudo su - postgres
    psql
    
  5. (Optional) Create a new database user:

    CREATE USER myuser WITH PASSWORD 'mypassword';
    
  6. (Optional) Create a new database:

    CREATE DATABASE mydb OWNER myuser;
    
  7. Exit PostgreSQL:

    \q
    

You have now successfully installed PostgreSQL on Debian.