Set up multiple Postgres Pro instances on Windows
To set up several Postgres Pro server instances with different data directories:
-
Install Postgres Pro as explained in GUI installation or Command-line installation sections. The installed binary files are shared by all Postgres Pro instances, so you need to complete this step only once.
-
Select an empty folder that your new Postgres Pro instance will use as the data directory. For example,
C:\Program Files\PostgresPro\12\data2. Grant Full Control permissions for this folder to the current OS user that will own the database files and to the user on behalf of which the server is running (NT AUTHORITY\NetworkServiceby default). -
Run
initdbspecifying the path to the new data directory and any other parameters required to initialize another server instance. For example:"C:\Program Files\PostgresPro\12\bin\initdb.exe" --encoding=UTF8 -U "postgres" -D "C:\Program Files\PostgresPro\12\data2"Alternatively, you can stop the running server and copy the contents of the existing data directory into the newly created folder. In this case, the new Postgres Pro instance inherits all the settings of the original instance, including authentication settings.
-
Modify
postgresql.confsettings for the new Postgres Pro instance as required. Specify different ports for your server instances to avoid conflicts. -
Open the command prompt as Administrator and register a new Postgres Pro service with a unique name. For example,
postgrespro-data2:"C:\Program Files\PostgresPro\12\bin\pg_ctl.exe" register -N "postgrespro-data2" -U "NT AUTHORITY\NetworkService" -D "C:\Program Files\PostgresPro\12\data2" -w -
Start the registered service:
sc start "postgrespro-data2"
Once the service is started, your Postgres Pro instance is ready to use. If you need any additional Postgres Pro extensions, enable them for the new instance as explained in Installing additional supplied modules.