PostgreSQL is a system to interact with a SQL relational database. It runs on Linux, Mac, Windows for C, Java, Python, Ruby, JavaScript and more.
To use PostgreSQL, I need to install it first. Here’s how to install PostgreSQL in Windows.
Step 1: Download from the Windows x86-64 column, download the latest version.
https://www.enterprisedb.com/downloads/postgres-postgresql-downloads
Step 2: Follow the Youtube tutorial below to install PG Admin 4. Choose the password and port, I chose port 3000.
Step 3: Go to System Properties, then Advanced, then Environment Variables, Choose Path under the System Variables box (lower box).


Step 4: Find where psql.exe is in, for me, it’s in C:\Program Files\PostgreSQL\16\bin and C:\Program Files\PostgreSQL\16\lib. Add C:\Program Files\PostgreSQL\16\bin in Path. Add C:\Program Files\PostgreSQL\16\lib in Path.

Step 5: If I still can’t in, check the pg_hba.conf file in \PostgreSQL\16\data folder, edit it with Notepad++. Scroll down, method is currently scram-sha-256, change it to trust.


Step 6: Open SQL Shell, skip everything by pressing enter. Then type in: ALTER USER postgres WITH PASSWORD ‘<password>’; <password> is my password, I need to remember that.
Step 7: Go back to pg_hba.config, scroll down, in the method section, change trust back to scram-sha-256.
Step 8: Go to Git Bash, type in psql -U postgres -p 3000 to get into PSQL shell, since I am port 3000. Enter the password, after that, I will be in PSQL shell.
Note: Since I am using port 3000, if another NodeJS app also uses port 3000, the NodeJS app will crash, I will have to use another port.
Optional: Since I initially changed the port to 3000 from default (5432), it’s advised to change the port back to default (5432), to do that, go to \PostgreSQL\16\data, edit the postgresql.conf file with Notepad++. Scroll down, change the port to 5432. Then restart the postgreSQL using service.msc. Now, the port should be 5432. If I want to access the database, I should type in psql -U postgres or psql -U postgres -p 3000.

Also, open PG Admin, right click on PostgreSQl server, choose properties. Go to Connection, change the port back to 5432.
