https://www.postgresql.org/download/
Download the installer certified by Enterprisedb for all supported PostgreSQL versions.
This installer includes the PostgreSQL server, pgadmin; A graphical tool for managing and developing your databases, and stackbuilder; A package manager, can be used to download and install additional PostgreSQL tools and drivers. Stackbuilder includes management, integration, migration, replication, geospatial, connectors and other tools.
You can download the Consolidated installation package: Includes PostgreSQL server,pgadmin A graphical interface client, Stackbuilder is responsible for managing integrated migration replication.
PostgreSQL's documentation was not friendly, I only found the Linux class system documentation. Then began to step on their own pits.
The file is exe if there is no DirectX or Microsoft Visual C + + redistributable (x64) ... Something like that it will automatically help install, so don't worry. (One of the reasons for choosing PostgreSQL is that MySQL's install-free package does not provide this type of support, manual is not resolved, other benefits are not yet available)
Setting environment variables
Create a new file with a VBS extension that reads as follows and double-click Execute.
On Error Resume Next set Sysenv=createobject ("Wscript.Shell"). Environment ("system") ' the array object of the systems environment variable Path = CreateObject ("Scripting.FileSystemObject"). GetFolder ("."). Path ' Add variable sysenv ("pghome") = "D:\pgsql" sysenv ("PGHOST") = "localhost" sysenv ("Path") =sysenv ("pghome") + "\ Bin;" +sysenv ("Path") sysenv ("Pglib") =sysenv ("pghome") + "\lib" sysenv ("PGDATA") =sysenv ("pghome") + "\data" WScript.Echo " PostgreSQL environment variable installed successfully! No need to restart the computer Ah! "
Initializing the database
At the command line, it is best to right-click Administrator privileges (which are also used below).
initdb.exe-d D:\pgsql\data-E UTF-8--locale=chs-u postgres-w
-D: Specifies the storage directory for the database cluster E:\pgsql\data
-e: Default encoding Format UTF8
--locale: About regional Settings (Chinese-simplified-china)
-U: Specifies the user name of the Super user for DB Postgres
-W: Tips for assigning passwords to super users
Installing Windows Services
Pg_ctl register-n postgresql-d D:\pgsql\data (be sure to have Administrator privileges)
Windows under PostgreSQL installation and configuration