Back to Setup

Windows Postgresql

_partials/windows_postgresql.md

latest1.3 KB
Original Source

PostgreSQL

Sometimes, SQLite is not enough and we will need a more advanced tool called PostgreSQL, an open-source robust and production-ready database system.

Let's install it now.

Run the following commands:

bash
sudo apt install -y postgresql postgresql-contrib libpq-dev build-essential
bash
sudo /etc/init.d/postgresql start
bash
sudo -u postgres psql --command "CREATE ROLE \"`whoami`\" LOGIN createdb superuser;"

📝 If you get an error saying could not change directory to "/home/your_name": Permission denied that is totally fine, and there's no need to worry 💆 If, on the first run, it says CREATE ROLE in the end all worked fine.

You can configure PostgreSQL to autostart, so you don't have to execute sudo /etc/init.d/postgresql start each time you open a new terminal:

bash
sudo echo "`whoami` ALL=NOPASSWD:/etc/init.d/postgresql start" | sudo tee /etc/sudoers.d/postgresql
bash
sudo chmod 440 /etc/sudoers.d/postgresql
bash
echo "sudo /etc/init.d/postgresql start" >> ~/.zshrc

Open a new terminal.

:heavy_check_mark: If you see a * Starting postgresql (via systemctl): postgresql.service OR * Starting PostgreSQL 14 database server message, you're good to go :+1:

:x: If not, contact a teacher.