0 / 2 embers
0 / 3000 xp
click for more info
Complete a lesson to start your streak
click for more info
Difficulty: 3
click for more info
No active XP Potion
Accept a Quest
Login to submit answers
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@15
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@15
sudo service postgresql start
Enter the psql
shell:
psql postgres
sudo -u postgres psql
You 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
to leave the psql
shell.
Run and submit the CLI tests.
The Boot.dev CLI requires you to be signed in to submit your solution!
Copy/paste one of the following commands into your terminal:
Run
bootdev run 74bea1f2-19cd-4ea9-966e-e2ca9dd1dfa9
Submit
bootdev run 74bea1f2-19cd-4ea9-966e-e2ca9dd1dfa9 -s
Run the CLI commands to test your solution.
Using the Bootdev CLI
The Bootdev CLI is the only way to submit your solution for this type of lesson. We need to be able to run commands in your environment to verify your solution.
You can install it here. It's a Go program hosted on GitHub, so you'll need Go installed as well. Instructions are on the GitHub page.