← WindowsSELECT * FROM Shiraverse · All Nukte
Get startedSetupWindows › Manual › PostgreSQL

Install PostgreSQL and pgAdmin 4 on Windows (step by step)

One official installer gives you PostgreSQL, pgAdmin 4 and psql. This page follows it screen by screen, from download to your first postgres=#.

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

▶ Watch the video

Windows › Manual › PostgreSQL

Install PostgreSQL and pgAdmin 4

PostgreSQL logo
PostgreSQLthe database engine
🖥️
pgAdmin 4see your data visually
⌨️
psqlthe command line tool

Ek installer, teen cheezein. One installer gives you all three.

The official Windows installer from EnterpriseDB gives you three things in one go: PostgreSQL (the database engine, where your data lives), pgAdmin 4 (a visual manager to browse tables and run queries) and psql (the command line tool, used to check everything works). This is the step-by-step way. If you prefer one command, use the one-command install.

Step 1

Download the installer

enterprisedb.com/downloads/postgres-postgresql-downloads
Choose the latest version, for Windows x86-64, and click the download button.

Hamesha official site se. Always download from the official site.

Open enterprisedb.com/downloads/postgres-postgresql-downloads. Pick the latest version for Windows x86-64 and download it. It is a big file, so give it a few minutes. Look in your Downloads folder for a file starting with postgresql- and ending in .exe.

Step 2

Run it and click Next

Setup - PostgreSQL
Welcome to the PostgreSQL Setup Wizard.
Installation DirectoryC:\Program Files\PostgreSQL\<version>
BackNext

Yahan default hi theek hai. The default folder is fine.

Double-click the downloaded .exe. If Windows asks "Do you want to allow this app to make changes?", click Yes. On the Welcome screen click Next. Keep the default Installation Directory and click Next. (The version number in the folder name will match the version you downloaded.)

Step 3

Pick the components

Setup - Select Components
PostgreSQL Serverthe database engine
pgAdmin 4visual manager
Command Line Toolsgives you psql
Stack Buildernot needed
BackNext

Teen tick, ek chhod do. Keep three ticked. Stack Builder we do not need.

On Select Components, keep these three ticked: PostgreSQL Server, pgAdmin 4 and Command Line Tools. You can leave Stack Builder unticked, because we do not use it. Click Next. On the next screen, the Data Directory, keep the default and click Next.

Step 4

Choose a password

Setup - Password
Please provide a password for the database superuser (postgres).
Password••••••••
Retype password••••••••
BackNext

Yeh password yaad rakhna. Remember this password. You need it every time.

Choose a password for the database super user, called postgres, and type it twice. Remember it, because you will need it to connect. For practice on your own laptop, a simple one like postgres is fine. Never use a simple password on a real server. Click Next.

Step 5

Keep port 5432

Setup - Port
Port5432
Locale[Default locale]
BackNext

Sab default rehne do. Leave everything on default.

Keep the Port as 5432. This is the standard PostgreSQL door number, and every tool in our course expects it. Keep Locale as [Default locale]. Click Next, check the Summary, and click Next once more.

Step 6

Wait for it, then Finish

Setup - Completing the PostgreSQL Setup Wizard
Setup has finished installing PostgreSQL on your computer.
Launch Stack Builder at exit?untick this
Finish

Thoda intezaar. Installing takes a few minutes. Untick Stack Builder, then Finish.

Click Next to start installing. It takes a few minutes. When it finishes, untick "Launch Stack Builder at exit" and click Finish.

Step 7

Check it works

Command Prompt– □ ×
C:\> psql -U postgres Password for user postgres: postgres=# postgres=# \q

See postgres=#? You are connected. Mubarak ho!

Open Command Prompt (Start, type cmd) and type:

psql -U postgres

Enter your password. If you see postgres=#, you are connected to your database. Type \q and press Enter to leave.

If Windows says psql is not recognized, add PostgreSQL to your PATH: open Edit the system environment variables, click Environment Variables, select Path, click Edit and New, and add C:\Program Files\PostgreSQL\<version>\bin (use the version number you installed). Then close and reopen Command Prompt.

Step 8

Open pgAdmin 4

NamePostgreSQL
Hostlocalhost
Port5432
Usernamepostgres
Passwordyour password

In pgAdmin: right-click Servers, Register, Server. Fill these in and Save.

Open pgAdmin 4 from the Start menu. The first time, it may ask you to set a master password. That is only for pgAdmin itself. Then right-click Servers, choose Register → Server, and fill in: Name PostgreSQL; on the Connection tab, Host localhost, Port 5432, Username postgres and your password. Click Save. If the server opens with a tree of databases, it worked.

If something goes wrong

Common problems

psql is not recognizedAdd C:\Program Files\PostgreSQL\<version>\bin to PATH, then open a new Command Prompt.
Forgot the postgres passwordOpen pgAdmin 4, right-click the server, Properties, and change it. If pgAdmin cannot connect either, uninstall and reinstall.
Service stoppedOpen Services (Start, type services.msc), find postgresql, right-click, Start.
pgAdmin connection errorCheck the service is running. Use host localhost and port 5432.

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

  • psql is not recognized: add C:\Program Files\PostgreSQL\<version>\bin to PATH, then open a new Command Prompt.
  • Forgot the postgres password: open pgAdmin 4, right-click the server, Properties, and change it. If pgAdmin cannot connect either, uninstall and reinstall.
  • Service stopped: open Services (Start, type services.msc), find postgresql, right-click, Start.
  • pgAdmin connection error: check the service is running, and use host localhost and port 5432.
Your turn

Did you see postgres=#?

sql.theshiraverse.com

Tell me in the comments. Milte hain agli video mein. Next: install VS Code.

Free SQL course and the Setup page, which maps every step. Join the WhatsApp Community, the Channel or Discord.

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