Installing PostgreSQL on Windows
Suggest editsYou can use the graphical installation wizard to install PostgreSQL on Windows.
When the PostgreSQL installation finishes, you can optionally invoke the Stack Builder package manager. Stack Builder provides a graphical interface for downloading and installing applications, drivers, utilities, and their dependencies. See Using Stack Builder for more information.
For information about preparing to use command-line tools after installation, see Command-line tools.
Downloading PostgreSQL
To download PostgreSQL installers, see the EDB downloads page.
Rather than use the EDB installer, you can also obtain a prebuilt installation package and instructions directly from the PostgreSQL downloads page.
Installing PostgreSQL
To perform an installation using the graphical installation wizard, you need superuser or administrator privileges.
Note
If you're using the graphical installation wizard to perform a system upgrade, the installer preserves the configuration options specified during the previous installation.
To start the installation wizard, assume sufficient privileges, and double-click the installer icon. If prompted, provide a password. (In some versions of Windows, to invoke the installer with administrator privileges, you must select Run as Administrator from the installer icon's context menu.)
The PostgreSQL setup wizard opens to the Welcome screen.
Select Next.
The Installation Directory window opens.
Accept the default installation directory, or specify a location. Select Next.
The Select Components window opens.
Use options on the Select Components window to choose the software components to install. Select:
- PostgreSQL Server to install the PostgreSQL database server.
- pgAdmin 4 to install pgAdmin 4. This option is available for PostgreSQL version 13.0 and later.
- Stack Builder to install the Stack Builder utility. For more information, see Using Stack Builder.
- Command Line Tools to install PostgreSQL tools such as
psql
,pg_isready
,pgbench
,clusterdb
,createdb
,dropdb
,createuser
,dropuser
,pg_basebackup
,pg_dump
,pg_dumpall
,pg_restore
,reindexdb
,vacuumdb
, andvacuumlo
. This isn't a comprehensive list, and the command-line tools installed can vary by platform.
Select Next.
The Data Directory window opens.
Accept the default location, or specify the directory where you want to store data files. Select Next.
The Password window opens.
PostgreSQL uses the password specified on the Password window for both the database superuser and the PostgreSQL service account.
PostgreSQL runs as a service in the background. The PostgreSQL service account is named
postgres
. If you already created a service account with the namepostgres
, you must specify the same password as the existing password for thepostgres
service account.The specified password must conform to any security policies on the PostgreSQL host.
Enter a password in the Password field, and confirm the password in the Retype Password field. Select Next.
The Port window opens.
In the Port field, enter the port number the server listens on. The default listener port is
5432
. Select Next.The Advanced Options window opens.
In the Locale field, specify the locale for the new database cluster to use. Default locale is the operating system locale. Select Next.
The Pre Installation Summary window opens. It displays the installation preferences that you specified with the installation wizard.
Review the settings. If necessary, use the Back button to return to a previous dialog box to modify a setting. When you're satisfied with the settings summary, select Next.
The wizard informs you that it has the information required to install PostgreSQL.
Select Next.
During the installation, the setup wizard confirms the installation progress of PostgreSQL using a series of progress bars.
Before the setup wizard completes the PostgreSQL installation, it offers to launch Stack Builder at exit. The Stack Builder utility provides a graphical interface that downloads and installs applications and drivers that work with PostgreSQL.
Leave the check box selected and select Finish to launch Stack Builder. Alternatively, clear the Stack Builder check box and select Finish to complete the PostgreSQL installation without launching Stack Builder.
Command-line tools
By default, the installer doesn't modify the system path. If you want to use command-line tools like psql
, you can add PostgreSQL to the path after installation.
Note
For information about the PostgreSQL interactive terminal psql
, see the Postgres guide.
To add PostgreSQL to the path:
- Open the System Properties control panel and select the Advanced tab. Alternatively, run
SystemPropertiesAdvanced.exe
. - Select Environment Variables to open the environment variables editor.
- Select the
Path
variable under System variables, and select Edit. - Add the path that you specified as the installation directory during installation, appended with
\bin
. By default, the value isc:\program files\postgresql\15\bin
, where15
is the version of PostgreSQL that you installed.
To test your installation, open a new command prompt and run:
You're prompted for the password you provided during installation.
Could this page be better? Report a problem or suggest an addition!