PostgreSQL – Install on Windows

PostgreSQL is a powerful open-source relational database management system. This guide will walk you through installing PostgreSQL on a Windows operating system.

Step 1: Download the PostgreSQL Installer

Visit the PostgreSQL Windows Download Page.

Download the PostgreSQL  Installer

Click on the “Download the installer” link to navigate to the EDB installer page.

Choose the appropriate version and architecture (32-bit or 64-bit) for your system, then download the installer.

Choose the appropriate version and architecture for PostgreSQL installation

Step 2: Run the PostgreSQL Installer

Locate the downloaded file and double-click it to start the installation process.

Run the PostgreSQL Installer
installation wizard

Follow the installation wizard:

Step 3: Configure PostgreSQL

Choose the installation directory (default is usually fine).

Choose the installation directory

Select the components to install (keep defaults: PostgreSQL server, pgAdmin, Stack Builder, etc.).

Select the PostgreSQL  components to install

Click “Next” to proceed through the setup steps.

Data Directory: The folder where database files will be stored. Leave the default or specify a custom location.

PostgreSQL Data Directory

Set Password: Enter a secure password for the `postgres` user (superuser). Let us go with 12345678 for the sake of tutorials, you may use your own password.

PostgreSQL - Set password

Port Number: By default, PostgreSQL uses port 5432. Ensure this port is not used by other services.

PostgreSQL - Select port

Locale: Choose a suitable locale for your database (default is usually fine)

PostgreSQL - Select Default Locale

Pre installation summary is shown. Click Next.

PostgreSQL - Pre installation summary

Setup is now ready to begin. Click Next.

PostgreSQL - Ready to install

Unpacking starts.

PostgreSQL - Installing
PostgreSQL

The setup is finish. Uncheck the option, and Click Finish.

Step 4: Complete Installation

  1. Once all configurations are set, the installer will copy files and set up PostgreSQL.
  2. After installation, you’ll see the option to launch Stack Builder. This tool can install additional components like extensions and drivers. You can skip this step for now if you don’t need them.
  3. Click “Finish” to complete the installation process.

Step 5: Verify Installation

Open the pgAdmin tool from the Start menu to access the PostgreSQL graphical interface.

Log in using the `postgres` username and the password you set during installation.

Create a new database or run a query to confirm the server is working as expected.

Step 6: Access PostgreSQL via Command Line

  1. Open the Command Prompt and navigate to the PostgreSQL `bin` directory. Example:
</>
Copy
cd "C:\Program Files\PostgreSQL\\bin"

Replace <version> with the installed version of PostgreSQL.

  1. Access the PostgreSQL shell with:
</>
Copy
psql -U postgres

Enter the password you set earlier to connect.

Conclusion

You’ve successfully installed PostgreSQL on your Windows machine. You can now use pgAdmin or the command-line interface to manage your databases and start developing with PostgreSQL.