Friday, November 15, 2024
Google search engine
HomeData Modelling & AIHow to Download and Install PostgreSQL on Windows

How to Download and Install PostgreSQL on Windows

Introduction

PostgreSQL is an open-source, object-based relational database management system. It is well-known for its robustness, SQL compliance, and extensibility.

In this tutorial, we will go over the step-by-step process of installing PostgreSQL on Windows 10. We will also show different ways to connect to a PostgreSQL database and verify the installation.

How to download and install PostgreSQL on WindowsHow to download and install PostgreSQL on Windows

Prerequisites

  • A system running Windows 10
  • Access to a user account with administrator privileges

Download PostgreSQL Installer

Before installing PostgreSQL, you need to download the installation file from the EDB website.

PostrgreSQL download page.PostrgreSQL download page.

Find the Windows x86-64 category for the latest version of PostgreSQL and click the Download button.

Note: For more information on installing PostgreSQL on other operating systems, check out our guide to installing PostgreSQL on Ubuntu.

Install PostgreSQL on Windows

Follow the steps below to install PostgreSQL on Windows:

1. Open the PostgreSQL install file to start the installation wizard. Click Next to continue.

2. Choose an install location for PostgreSQL and click Next to proceed.

Choose the PostgreSQL install locationChoose the PostgreSQL install location

3. Select which software components you want to install:

  • PostgreSQL Server: Installs the PostgreSQL database server.
  • pgAdmin 4: Provides a graphical interface for managing PostgreSQL databases.
  • Stack Builder: Allows you to download and install additional tools to use with PostgreSQL.
  • Command Line Tools: Installs the command line tool and client libraries. Required when installing PostgreSQL Server or pgAdmin 4.
Select the software components you want to installSelect the software components you want to install

Once you check the boxes next to the components you want to install, click Next to continue.

4. Choose a database directory to store data and click Next to continue.

Choose the directory where PostgreSQL will save your dataChoose the directory where PostgreSQL will save your data

5. Enter and retype the password for the database superuser. Click Next to proceed.

Set a password for the database superuserSet a password for the database superuser

Note: PostgreSQL runs as a background process under a service called postgres. If you already have a service named postgres running, enter the password for that service account when prompted.

6. Enter the port number for the PostgreSQL server to listen on and click Next to continue.

Set the PostgreSQL server port numberSet the PostgreSQL server port number

Note: The default port number for the PostgreSQL server is 5432. When entering a custom port number, make sure no other applications are using the port.

7. Choose the locale for the database to use. Selecting the [Default locale] option uses the locale settings for your operating system. Once you have chosen a locale, click Next to continue.

Choose a locale for the new databaseChoose a locale for the new database

8. The last step offers a summary of the installation settings. Click Back if you want to change any of the settings you made, or click Next to proceed.

Review the setup summaryReview the setup summary

9. The setup wizard informs you it is ready to start the installation process. Click Next to begin installing PostgreSQL.

Click Next to start the PostgreSQL installation processClick Next to start the PostgreSQL installation process

Connect to the PostgreSQL Database

You can verify the new PostgreSQL installation by connecting to the database using the SQL shell or the pgAdmin tool:

Connect to the PostgreSQL Database Using the SQL Shell (psql)

1. Open the SQL Shell (psql) in the PostgreSQL folder in the Start menu.

2. Enter the information for your database as defined during the setup process. Pressing Enter applies the default value, as shown in the square brackets.

Enter the database information into the SQL shellEnter the database information into the SQL shell

3. Verify the new database by using the command:

select version();
Check the database version to verify the installationCheck the database version to verify the installation

Note: For more details on PostgreSQL version commands, check out our article on how to check PostgreSQL version.

Connect to the PostgreSQL Database Using pgAdmin

1. Open the pgAdmin 4 tool from the PostgreSQL folder in the Start menu.

Note: pgAdmin requires you to set a master password at first launch.

2. Right-click the Servers icon on the left-hand side. Select Create > Server to set up a new database server.

Create a new database server in pgAdminCreate a new database server in pgAdmin

3. In the General tab, enter the name for the new database. In this example, we are using PostgreSQL as the database name.

Set the name for the new database serverSet the name for the new database server

4. In the Connection tab, enter the hostname (default is localhost) and password selected during the setup process. Click Save to create the new database.

Set the hostname and password and save changes to create a new database serverSet the hostname and password and save changes to create a new database server

5. Expand the server display by clicking on the Servers > PostgreSQL icons on the left-hand side. Select the default postgres database.

Expand the server display to see the new database.Expand the server display to see the new database.

6. In the Tools drop-down menu, click Query Tool to open the query editor.

Select the new database and open the query tool.Select the new database and open the query tool.

7. Verify the database in the query editor by entering the following command and clicking the Execute button:

select version();

If the database is working properly, the current version of the database will appear in the Data Output section.

Verify the new PostgreSQL database in the query editor.Verify the new PostgreSQL database in the query editor.

Conclusion

After following this tutorial, you should have PostgreSQL installed and working on your Windows system. You should also have your first PostgreSQL database set up and ready to use.

Was this article helpful?
YesNo

RELATED ARTICLES

Most Popular

Recent Comments