Install PostgreSQL and PostGIS in Windows environment

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.


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.
insert image description here

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.
insert image description here

Select the components to install. It is recommended to uncheck "Stack Builder" here
insert image description here

Select data storage path
insert image description here

set password.
insert image description here

Set the port number (5432 by default)
insert image description here

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)
insert image description here

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.
insert image description here

Select the components to install. Optional is a sample database.
insert image description here

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.
insert image description here

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.
insert image description here

Open the service browsing panel on the left, and it will automatically connect to the installed PostgreSQL on the machine.
insert image description here

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".
insert image description here

Enter the connection name and parameters, and click Save to connect to the database.
insert image description here
insert image description here

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.
insert image description here

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.
insert image description here

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.
insert image description here

Guess you like

Origin blog.csdn.net/lordwish/article/details/125753892