Summary: In this tutorial, you will learn step by step how to install PostgreSQL on your local system.
Install PostgreSQL on macOS Install PostgreSQL
- on Linux PostgreSQL
developed for UNIX-like platforms, however, it was designed to be portable. This means that PostgreSQL can also run on other platforms such as macOS, Solaris, and Windows.
Since version 8.0, PostgreSQL offers an installer for Windows systems that makes the installation process easier and faster. For development purposes, we will install PostgreSQL version 12 on Windows 10.
There are three steps to complete the PostgreSQL installation:Download PostgreSQL installer for Windows Install PostgreSQL Verify installation
1) Download PostgreSQL Installer for Windows
First, you need to go to the download page of
- the PostgreSQL
Secondly, click the download link as shown below:
It will take a few minutes to complete the download
. 2) Install PostgreSQL on Windows step
by step To install PostgreSQL on Windows, you must have administrator privileges.
Step 1. Double click on the installer file, an installation wizard will appear guiding you through multiple steps where you can choose different options you would like to have in PostgreSQL.
Step 2. Click the Next
Step 3. Specify the installation folder, choose your own, or keep the default folder suggested by the PostgreSQL installer and click the Next
Step 4. Select the software components you want
to install:The PostgreSQL server to install the PostgreSQL database server
- pgAdmin 4 to install the PostgreSQL database GUI administration tool.
- for installing command-line tools such as psql, pg_restore, etc. These tools allow you to interact with the PostgreSQL database server using the command line interface.
- Stack Builder provides a GUI that allows you to download and install drivers that work with PostgreSQL.
For the tutorial on this website, you don’t need to install Stack Builder, so feel free to uncheck it and click the Next button to select the data directory:
Step 5. Select the database directory to store the data or accept the default folder. And click the Next button to go to the next step:
Step 6. Type the password for the database superuser (
PostgreSQL runs as a background service under a service account named postgres. If you have already created a service account with the name postgres, you must provide the password for that account in the next window.
After entering the password, you need to retype it to confirm and click the Next button:
Step 7. Enter a port number on which the PostgreSQL database server will listen. The default PostgreSQL port is 5432. You must ensure that no other applications are using this port.
Step 8. Choose the default locale used by the PostgreSQL database. If you leave it as the default locale, PostgreSQL uses the locale of the operating system. After that, click on the Next button.
Step 9. The configuration wizard will display PostgreSQL summary information. You should review it and click on the Next button if everything is correct. Otherwise, you should click the Back button to change the settings accordingly.
Now, you are ready to install PostgreSQL on your computer. Click the Next button to begin installing PostgreSQL.
The installation may take a few minutes to complete
Step 10. Click the Finish button to complete the PostgreSQL installation.
There are several ways to verify your PostgreSQL installation. You can try to connect to the PostgreSQL database server from any client application, for example, psql and pgAdmin.
The fastest way to verify the installation is through the psql program.
First, click on the psql application to launch it. The psql command-line program is displayed.
Secondly, enter all the necessary information such as server, database, port, username and password. To accept the default, you can press Enter. Note that you must provide the password you entered during PostgreSQL installation.
Code language: Shell Session (shell)
Third, run the SELECT version() command; you will see the following output:
Congratulations! you have successfully installed the PostgreSQL database server on your local system. Let’s learn several ways to connect to the PostgreSQL database server.