Installing PostgreSQL
Harry
· 11 Sep 2026
· 11 views
Installing on Ubuntu / Debian
sudo apt update
sudo apt install postgresql postgresql-contrib
sudo systemctl enable --now postgresql
sudo -u postgres psqlOn Debian-family systems the postgres OS user owns the database cluster. Connect as that user first.
Setting a Password and Creating a User
sudo -u postgres psql
ALTER USER postgres PASSWORD 'strong_password';
CREATE ROLE app_user LOGIN PASSWORD 'app_password';
CREATE DATABASE appdb OWNER app_user;
\qConnecting With psql
psql -h localhost -U app_user -d appdb -WVerifying the Install
psql --version
sudo systemctl status postgresql
sudo -u postgres psql -c "SELECT version();"Installing on Windows / macOS
Use the interactive EDB installer for Windows, or Homebrew on macOS with brew install postgresql. The EDB installer starts the service and gives you pgAdmin automatically.
Key Points
- The
postgressuperuser is created during install. - Create separate roles (users) for applications.
- psql is the powerful command-line client.
- Verify with
psql --versionand a version query.