How to Install PostgreSQL 17 on Windows 11: A Complete Guide for 2024

Postgresql

Visual excerpt from the YouTube channel Geeky Script. All rights belong to the original creator.

PostgreSQL, one of the most popular open-source relational database management systems, has seen significant updates over the years. As of 2024, the latest version is PostgreSQL 17, which brings several new features and improvements. If you're looking to install PostgreSQL 17 on a Windows 11 system, this step-by-step guide will walk you through the process. We will also cover how to use pgAdmin 4, the graphical user interface for managing PostgreSQL, so you can start creating and managing databases with ease.


Step 1: Downloading PostgreSQL 17

To begin, you'll need to download the PostgreSQL 17 installer for Windows. Here's how to do it:

  1. Open Your Browser: Launch your preferred web browser (such as Google Chrome or Microsoft Edge).
  2. Search for PostgreSQL: In the search bar, type "PostgreSQL 17 download" and press Enter.
  3. Visit the Official PostgreSQL Website: Click on the first search result, which should take you to the official PostgreSQL download page at https://www.postgresql.org/download/.
  4. Choose Your Operating System: On the download page, you will see various operating system options (Linux, macOS, Windows, etc.). Since you're using Windows, click the "Windows" option.
  5. Download the Installer: On the next page, you'll see different versions of PostgreSQL available. Look for PostgreSQL 17 and click the "Download the Installer" link. The file size is approximately 370 MB, so the download might take a few minutes depending on your internet speed.

Step 2: Installing PostgreSQL 17

Once the installer has finished downloading, follow these steps to install PostgreSQL 17 on your Windows 11 machine:

  1. Run the Installer: Navigate to your "Downloads" folder and double-click the downloaded .exe file. If prompted for administrative privileges, click "Yes" to proceed.
  2. Setup Wizard: The PostgreSQL installation wizard will launch. Click "Next" to continue.
  3. Choose Installation Directory: By default, PostgreSQL will be installed in the C:\Program Files\PostgreSQL\17 directory. You can change this location if necessary, but the default path should be fine for most users.
  4. Select Components: The setup will prompt you to choose the components to install. Make sure that "PostgreSQL Server" and "pgAdmin 4" are selected. pgAdmin is the graphical user interface used to interact with the database. You may also choose to install other tools like Stack Builder (for downloading additional tools) and command-line utilities.
  5. Set Password for Superuser: During the installation, you will be asked to set a password for the postgres user (the default superuser). Choose a secure password and remember it—you'll need it later.
  6. Select Port Number: The default port for PostgreSQL is 5432. It's recommended to leave this as the default unless you have a specific reason to change it.
  7. Installation Summary: Review your selections, click "Next", and then click "Install". The installation process may take a few minutes.

Once the installation is complete, you will see a confirmation message. Click "Finish" to close the installer.


Step 3: Configuring PostgreSQL with Stack Builder (Optional)

After the installation, the Stack Builder tool will open, allowing you to install additional drivers and software packages for PostgreSQL. If you don't need any extra tools, you can simply close this window and proceed. However, if you'd like to install drivers or extensions such as PostGIS (for geographic data) or ODBC drivers, you can use Stack Builder to download and install them.

Step 4: Launching pgAdmin 4

Once PostgreSQL is installed, you can use pgAdmin 4 to interact with your database. Here's how to get started:

  1. Open pgAdmin:
    Go to the Start menu and search for "pgAdmin 4". Click on the application to open it.
  2. Connect to PostgreSQL:
    When pgAdmin launches, it will ask you for the password you created during installation. Enter the password and click OK to connect to your PostgreSQL server.
  3. Create a New Database:
    Once connected, you can begin creating databases. In the pgAdmin dashboard, right-click on the "Databases" node in the Object Browser and select Create → Database.
    Name your new database (e.g., players) and click Save.

Step 5: Creating Tables and Inserting Data

Now that your database is set up, let's create a table and insert some data using pgAdmin 4.

  1. Create a Table:

    • In pgAdmin, expand your newly created database (e.g., players) in the Object Browser.
    • Right-click on Tables and select Create → Table.
    • Define the table structure — for example, create a table called ch_players with columns for id (integer) and name (varchar).

    Here's an example SQL query to create the table:

    CREATE TABLE ch_players (
        id INT PRIMARY KEY,
        name VARCHAR(255)
    );
    

    After writing the SQL query, click the Execute button (the lightning bolt icon) to run the query.

  2. Insert Data into the Table:

    • Now, let’s insert some data into the ch_players table using the following SQL queries:
    INSERT INTO ch_players (id, name) VALUES (1, 'Vand');
    INSERT INTO ch_players (id, name) VALUES (2, 'DGES');
    

    Click the Execute button again to insert the data.

  3. Fetch Data:

    • To view the data in your table, run a SELECT query:
    SELECT * FROM ch_players;
    

    This will display the data you just inserted in the query results pane.


Step 6: Additional Configuration and Tools

If you need more advanced configurations or tools, pgAdmin allows you to manage PostgreSQL features such as functions, views, and procedures. You can also use the SQL Query Tool in pgAdmin to execute custom SQL queries, back up and restore databases, and perform other administrative tasks.