The method of downloading and configuring PostgreSQL database under Windows _postgresql

Source: Internet
Author: User
Tags locale postgresql

Note that the download is a binary sedan, not with Windows Installer.

Http://www.enterprisedb.com/products-services-training/pgbindownload

x86 download Http://get.enterprisedb.com/postgresql/postgresql-9.2.4-1-windows-binaries.zip
x64 Download Http://get.enterprisedb.com/postgresql/postgresql-9.2.4-1-windows-x64-binaries.zip

Before performing the following steps, tentatively assume the following:
PostgreSQL to be fitted in D:\postgresql
The database is intended to be stored in D:\postgresql\data

First download Postgresql-9.2.4-1-windows-x64-binaries.zip the latest version to be used, the following steps to achieve the manual installation of PostgreSQL, initialize the database, the PostgreSQL registration as a service.

1, Postgresql.zip decompression to D:\postgresql, create a data directory;

2. Set environment variables, edit batch files configure environment variables. VBS (PERMANENT)

A) The contents are as follows

On Error Resume Next
set Sysenv=createobject ("Wscript.Shell"). Environment ("system") ' Array object
Path = CreateObject (' Scripting.FileSystemObject ') for system environment variables. 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 installation success!" You don't need to restart your computer! "

b) implemented as follows:

3, in the blank place hold shift Click the right mouse button, new open a CMD window, and CD to D:\postgresql\bin;

4. Initialize and create the database (once)

initdb.exe-d D:\postgresql\data-E UTF-8--locale=chs-u postgres-w

-D: Specifies the storage directory for the database cluster E:\pgsql\data

-E: Specifies the user name of the superuser for DB Postgres

--locale: About regional Settings (Chinese-simplified-china)

-u: Default encoding format CHS

-W: Tips for assigning passwords to super users

As follows:

4. Start the database

Note: If you are not registered as a system service, you need to manually start each time, otherwise the PGADMIN3 connection database fails

pg_ctl-d d:\postgresql-l logfile Start

The display is as follows:

After startup, generate a logfile file in the home directory where the database is installed: D:\postgresql\logfile

5. Registration for WIN8 system services

Note: Administrator privileges are required to

Pg_ctl register-n postgresql-d D:\postgresql\data

View Registered Services: Win+r in the pop-up Run box, enter: Services.msc, as follows:

net start PostgreSQL to see if it starts: command-line Input tasklist

Netstat–an can view all IP uninstall services that establish a connection to the local computer: Administrator privileges are also required, two ways

1) pg_ctl unregister–n PostgreSQL (WIN8)

2 SC Delete PostgreSQL (PostgreSQL)

6. Configure the PGADMIN3 client

Directory for D:\postgresql\bin\ pgAdmin3, double-click, configure

7. Connection Database Successful

How do I get PostgreSQL to support remote logins?

Only need to configure on the server side
Modify two files:

Postgresql.conf
Pg_hba.conf

-----------------
For example, the DB server IP in the environment is 10.10.3.5,
The IP of the client is 10.10.3.5

Add in postgresql.conf file:
listen_addresses = ' * '

Add in pg_hba.conf file:
Host All 10.10.3.1/24 Trust
24 indicates that the mask is 255.255.255.0, so it is open for all IP on this subnet.
You can visit 10.10.3.5 on the 10.10.3.5.

Perform after completion
C:\windows\system32>net Stop PostgreSQL
C:\windows\system32>net Start PostgreSQL

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.