Skip to content

Instantly share code, notes, and snippets.

@okurka12
Created May 7, 2025 09:20
Show Gist options
  • Save okurka12/a3d13a7ee48e0bb77fb3ce699d8517e5 to your computer and use it in GitHub Desktop.
Save okurka12/a3d13a7ee48e0bb77fb3ce699d8517e5 to your computer and use it in GitHub Desktop.
Instructions for installing and running PostgreSQL locally

How to install + setup PostgreSQL (on Debian Linux)

Following steps are for starting a PostgreSQL database locally on your machine and accessing it as a postgres user.

Install the package

sudo apt install postgresql

  • note down the version with psql --version

Start the service

sudo systemctl start postgresql (Normal debian using systemd)

sudo service postgresql start (WSL2 without systemd)

Acces the SQL prompt as the postgres user

sudo -u postgres psql

Set a password for the postgres user

\password postgres

Then, save the password you chose to your config files.

Create/remove database

sudo -u postgres createdb NAME

sudo -u postgres dropdb NAME

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment