← WindowsSELECT * FROM Shiraverse · All Nukte
Get startedSetupWindows › One-command install

Install PostgreSQL on Windows with one command

One PowerShell command installs everything you need for this course: PostgreSQL, pgAdmin 4, VS Code and Git. Then you check that it worked. Takes about 20 to 30 minutes, mostly waiting. No experience needed.

Jo video mein bola, yahan nukte mein likha hai.
What I said in the video, written here as key points.

▶ Watch the video

Get started › Setup › Windows › One-command

One command.
Four tools.

PostgreSQL logo
PostgreSQLthe database engine
🖥️
pgAdmin 4see your data visually
📝
VS Codewrite your SQL files
🌿
Gitsave your work

Ek command, saara setup. One command sets up everything on your Windows PC.

This is the fast way to set up your laptop for the course. One script installs the four tools we use: PostgreSQL (the database engine, where your data lives), pgAdmin 4 (a visual manager to browse tables and run queries), VS Code (an editor for writing .sql files) and Git (version control for your work). It also creates an empty database called practice for your own tables.

Before you start

Three things you need

Thoda sabr rakhna. Be patient. It takes about 20 to 30 minutes, mostly waiting.

You need a Windows 10 or 11 PC, an internet connection, and permission to run PowerShell as administrator. The script uses winget (Windows Package Manager), which comes with Windows 11. On Windows 10, update "App Installer" from the Microsoft Store first. Plan for about 20 to 30 minutes, most of it waiting for downloads.

Step 1 of 3

Download the installer

📄
install_windows.ps1from sql.theshiraverse.com/setup
📁
Downloadskeep it there, we will run it from that folder

Pehle file utaaro. First, get the file onto your PC.

Download install_windows.ps1 and leave it in your Downloads folder. It is a plain text script, so you can open it in Notepad and read exactly what it does before running it. The installer file is also on the Setup page.

Step 2 of 3

Open PowerShell as administrator

1
Click Startthe Windows button
2
Type "PowerShell"Windows PowerShell appears
3
Right-click itchoose Run as administrator
4
Click Yesthe window title says Administrator
Administrator: Windows PowerShell– □ ×
PS C:\WINDOWS\system32>

Admin ke bina install nahi hoga. Without admin, the install will stop.

Click Start, type PowerShell, right-click Windows PowerShell and choose Run as administrator, then click Yes. Check the window title says Administrator. If you skip this, the script stops straight away with "This script must be run as Administrator".

Step 3 of 3

Type three lines

Administrator: Windows PowerShell– □ ×
PS> cd $HOME\Downloads PS> Set-ExecutionPolicy -Scope Process -ExecutionPolicy Bypass PS> .\install_windows.ps1
cd $HOME\DownloadsGo to the folder where the file is.
Set-ExecutionPolicy ...Allow scripts to run in this window only. It resets when you close it.
.\install_windows.ps1Start the installer. Then wait.

Bas teen line. Just three lines. Press Enter after each one.

In the administrator PowerShell window, type these three lines, pressing Enter after each. You can copy them from the Setup page.

cd $HOME\Downloads
Set-ExecutionPolicy -Scope Process -ExecutionPolicy Bypass
.\install_windows.ps1

The first line moves into the Downloads folder. The second allows scripts to run in this window only, and the setting disappears when you close it. The third starts the installer.

While you wait

What the script is doing

Let it finish. Wait until you see Installation Complete!

While it runs, the script does these things in order: checks you are administrator, checks winget, installs PostgreSQL (with pgAdmin 4), adds PostgreSQL to your PATH, starts the database and waits for it, creates the postgres user and an empty practice database, then installs VS Code and Git. Anything you already have is skipped. Wait until you see "Installation Complete!" before you close the window.

At the end

Your connection details

Hostlocalhost
Port5432
Userpostgres
Passwordpostgres
Databasepractice

Yeh sirf practice ke liye hai. This simple password is for practice on your own laptop only. Never use it on a real server.

At the end the script prints these details. Save a screenshot of them.

The password postgres is fine for practice on your own laptop, and it is never exposed to the internet. Want your own? Before you run the script, type $env:PG_PASSWORD = "your-password" in the same window.

Check it worked

Close it. Open a new one.

Windows PowerShell– □ ×
PS> psql --version psql (PostgreSQL) <version> PS> git --version git version 2.x PS> code --version 1.x PS> psql -h localhost -U postgres -d practice Password for user postgres: practice=#

See practice=#? You are connected. Type \q to leave. Mubarak ho! Congratulations.

Close the PowerShell window and open a new one. This time a normal window is fine. A new window matters: PATH changes only show up in windows opened after the install.

psql --version
git --version
code --version
psql -h localhost -U postgres -d practice

The first three should print version numbers. The last one asks for your password (postgres unless you changed it) and then shows the prompt practice=#. That means you are connected to your own database. Type \q and press Enter to leave. Then open pgAdmin 4 from the Start menu and check that it connects too.

If something goes wrong

Five common problems

"running scripts is disabled"Run the Set-ExecutionPolicy line again in the same window.
"must be run as Administrator"Close it and reopen PowerShell with Run as administrator.
"winget not found"Install App Installer from the Microsoft Store, then run again.
psql is not recognizedOpen a new PowerShell window. Still no? Restart the PC.
PostgreSQL did not startRun Get-Service postgresql-x64-* and check it says Running.

Still stuck? Tell me exactly what the screen says. Ghabrana nahi.

The common problems and their fixes:

  • "running scripts is disabled": run the Set-ExecutionPolicy -Scope Process -ExecutionPolicy Bypass line again in the same window.
  • "This script must be run as Administrator": close the window and reopen PowerShell with Run as administrator.
  • "winget not found": install App Installer from the Microsoft Store, then run the script again.
  • psql is not recognized: open a new PowerShell window. If it still fails, restart the PC.
  • "PostgreSQL didn't accept connections": run Get-Service postgresql-x64-* and check the status says Running.

More fixes are on the Windows check page. If you are stuck, tell me exactly what the screen says in the comments or in the community.

Your turn

Did you see practice=#?

Tell me in the comments. Milte hain agli video mein. Next: load the RetailMart database onto your laptop.

sql.theshiraverse.com

Free SQL course, a real 55-table database, and a step-by-step Setup page. Join the WhatsApp Community, the Channel or Discord. More from Shiraj at theshiraverse.com.

→ / Space next   ← back   F fullscreen   H hide bars   N notes