PostgreSQL is a production-ready, open-source database. It's a great choice for many web applications, and as a back-end engineer, it might be the single most important database to be familiar with.
Postgres, like most other database technologies, is itself a server. It listens for requests on a port (Postgres' default is :5432), and responds to those requests. To interact with Postgres, first you will install the server and start it. Then, you can connect to it using a client like psql or PGAdmin.
macOS with brew
brew install postgresql@16
Linux / WSL (Debian). Here are the docs from Microsoft, but simply:
sudo apt update
sudo apt install postgresql postgresql-contrib
psql --version
sudo passwd postgres
Enter a password, and be sure you won't forget it. You can just use something easy like postgres.
brew services start postgresql@16sudo service postgresql startEnter the psql shell:
psql postgressudo -u postgres psqlYou should see a new prompt that looks like this:
postgres=#
CREATE DATABASE gator;
\c gator
You should see a new prompt that looks like this:
gator=#
ALTER USER postgres PASSWORD 'postgres';
For simplicity, I used postgres as the password. Before, we altered the system user's password, now we're altering the database user's password.
From here you can run SQL queries against the gator database. For example, to see the version of Postgres you're running, you can run:
SELECT version();
You can type exit or use \q to leave the psql shell.
Run and submit the CLI tests.