Environment: Win7 SP1
pg:9.3.5
1, create user postgres, password is also postgres:
NET user Postgres Postgres/add
2, in the database root directory to create a data directory:
C:\Program FILES\POSTGRESQL\9.3>MD Data
3, remove the administrator of the Data directory permissions:
C:\Program files\postgresql\9.3>cacls data/e/t/r Administrator
Processed directory: C:\Program files\postgresql\9.3\data
4. Assign the data directory permissions to Postgres users:
C:\Program files\postgresql\9.3>cacls data/e/t/g postgres:c
Processed directory: C:\Program files\postgresql\9.3\data
5. Open cmd with postgres user
C:\Program files\postgresql\9.3>runas/user:postgres Cmd.exe
Enter Postgres password:
Attempt to start Cmd.exe as user "Sure-pc\postgres" ...
6, Initialize, initialize user to Postgres, character set to Utf8,locale as C:
C:\Program files\postgresql\9.3\bin>initdb.exe-d.
/data-e UTF8--locale c-u postgres The files belonging to this database system'll be owned by user "Postgres".
This user must also own the server process.
The database cluster is initialized with locale "C".
The default text search configuration is set to "中文版".
The Data page checksums are disabled. Fixing permissions on existing directory. /data ... ok creating subdirectories ... ok selecting default Max_connections ... Selecting Default Shared_buffers ... 128MB Creating configuration files ... ok creating template1 database in.. /data/base/1 ... ok initializing pg_authid ... ok initializing dependencies ... ok creating system views ... okay loading sy Stem objects ' descriptions ... ok creating collations ... not supported to this platform creating ... OK conversions ing dictionaries ... ok setting privileges on built-in objects ... ok creating information schema ... ok loading pl/pgsql Server-side LANGuage ... ok vacuuming database template1 ... ok copying template1 to template0 ... ok copying template1 to Postgres ... o K Syncing data to disk ... ok warning:enabling ' trust ' authentication for local connections you can change this by edit
ing pg_hba.conf or using the option-a, or--auth-local and--auth-host, the next time for you run INITDB. Success. You can now start the database server using: "Postgres"-D ". /data "or" Pg_ctl "-D" ... /data "-l logfile start C:\Program files\postgresql\9.3\bin>
7, start the database, access to the client:
C:\Program files\postgresql\9.3\bin> "Pg_ctl"-D ". /data "Start
server starting
C:\Program files\postgresql\9.3\bin>log:database system is shut down at 2014-< c3/>09-18 10:19:54 HKT
log:autovacuum launcher started C:\Program files\postgresql\9.3\bin>log:database
System is ready to accept con
nections
C:\Program files\postgresql\9.3\bin>psql.exe psql
(9.3.5)
Type ' help ' for help.
postgres=#