Databases

Install PostgreSQL

PostgreSQL installed directly on your machine, running in the background.

  1. Install PostgreSQL 17
    Terminal
    brew install postgresql@17
  2. Start it now and on every login
    Terminal
    brew services start postgresql@17
  3. Put psql on your PATH
    Terminal
    echo 'export PATH="/opt/homebrew/opt/postgresql@17/bin:$PATH"' >> ~/.zshrc
    source ~/.zshrc

Check it worked

  1. Connect to it
    Terminal
    psql postgres -c "SELECT version();"
Undo it
  1. Stop and uninstall
    Terminal
    brew services stop postgresql@17 && brew uninstall postgresql@17
  1. Install PostgreSQLNeeds sudo
    Terminal · Ubuntu / Debian
    sudo apt install -y postgresql
  2. Start it now and on every bootNeeds sudo
    Terminal · Ubuntu / Debian
    sudo systemctl enable --now postgresql

Check it worked

  1. Connect to it
    Terminal · Ubuntu / Debian
    sudo -u postgres psql -c "SELECT version();"
Undo it
  1. Uninstall PostgreSQLNeeds sudo
    Terminal · Ubuntu / Debian
    sudo apt remove -y postgresql
  1. Install PostgreSQL 17
    PowerShell
    winget install PostgreSQL.PostgreSQL.17

    The installer asks you to set a password for the postgres user. Keep it somewhere safe.

  2. Put psql on your PATH
    PowerShell
    [Environment]::SetEnvironmentVariable("Path", [Environment]::GetEnvironmentVariable("Path", "User") + ";C:\Program Files\PostgreSQL\17\bin", "User")

    Close and reopen PowerShell afterwards.

Check it worked

  1. Connect to it
    PowerShell
    psql -U postgres -c "SELECT version();"
Undo it
  1. Uninstall PostgreSQL
    PowerShell
    winget uninstall PostgreSQL.PostgreSQL.17