The previous article is how to install PostgreSQL and PostGIS in Docker. This article will record how to install PostgreSQL and PostGIS in the Windows environment.
Article directory
Installation Environment
Windows Server 2016
PostgreSQL 10.21
PostGIS 10.3
The download addresses are:
PostgreSQL: https://www.enterprisedb.com/downloads/postgres-postgresql-downloads
PostGIS: https://www.postgresql.org/ftp/postgis/
PostgreSQL installation
Open the installation package with administrator privileges to start the installation.
Set the installation path to "C:\DataBase\PostgreSQL\10" or other paths, do not install to the default path C:\ProgramFiles, otherwise the directory may not be accessible due to permission issues and the service may not start normally.
Select the components to install. It is recommended to uncheck "Stack Builder" here
Select data storage path
set password.
Set the port number (5432 by default)
Select the default "Default locale" for the localization option, do not select the Chinese option (Chinese Simplest), otherwise the installation will fail. (I don't know the reason, if you try to select Chinese many times, the installation will fail)
Click Next to continue and wait for the installation to complete.
PostGIS plugin installation
The PostGIS plug-in version needs to be consistent with the main version of PostgreSQL, and the PostGIS component must be installed; otherwise, geographic information-related data cannot be used.
Run the installation file as an administrator.
Select the components to install. Optional is a sample database.
Select the installation path. If you want to install PostGIS to the PostgreSQL installation directory, you need to stop the postgresql service in advance, otherwise the installation file will fail to be written. Remember to start the postgresql service after the installation is complete.
Click Next to continue until the installation is complete.
pgAdmin management tool
Open the management tool pgAdmin in the start menu, and you will be asked to set a login password for the first startup.
Open the service browsing panel on the left, and it will automatically connect to the installed PostgreSQL on the machine.
If there is no connection, you can manually add the database service. Click "Servers" on the left panel to display "Dashboard", click "Add New Server".
Enter the connection name and parameters, and click Save to connect to the database.
Data Backup and Restore
Use pgAdmin to connect to the database.
Right click on "DataBase" and select "Create–DataBase". Enter the database name and select "postgres" for the Owner.
Right-click on the one that needs to be restored and select Restore, select the backup file name (FileName), and select the role name (Rolename) as postgres.
Click Restore to start the restore.
If the backup file restoration dialog box cannot appear during the operation, check "File—Preference—Binary Path", find the configuration item of the current version, and change the path to the installation directory of the current version.
Uninstallation and cleaning of PostgreSQL and PostGIS
In the Windows environment, uninstall normally in "Control Panel - Programs and Features - Uninstall or change a program".
Enter "regedit" in the running window (Windows+R) to open the registry editor, find "HKEY_LOCAL_MACHINE\SOFTWARE", delete the registry entries related to PostGIS and PostgreSQL, and the cleaning is completed.