How to download and configure Postgresql databases in Windows

Source: Internet
Author: User

Note that the download is a binary version, not a 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, make the following assumptions:
PostgreSQL to be installed in d: \ postgresql
The database will be stored in d: \ postgresql \ data later.

Download the latest version of postgresql-9.2.4-1-windows-x64-binaries.zip. Follow these steps to manually install PostgreSQL, initialize the database, and register PostgreSQL as a service.

1. Unzip postgresql.zip to d: \ postgresql and create a data directory;

2. Set the environment variable and edit the environment variable of the batch file configuration. vbs (valid permanently)

A) the content is as follows:

On error resume nextset sysenv = CreateObject ("WScript. shell "). environment ("system") 'array object of the system 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 installation successful! No need to restart the computer! "

B) perform the following:

3. Right-click shift in the blank space, open a new cmd window, and cd to d: \ postgresql \ bin;

4. initialize and create a database (once)

Initdb.exe-D d: \ postgresql \ data-E UTF-8 -- locale = chs-U postgres-W

-D: Specifies the storage directory of the Database Cluster E: \ pgsql \ data

-E: Specify the database superuser username postgres

-- Locale: About region settings (chinese-simplified-china)

-U: the default encoding format is chs.

-W: Prompt for specifying a password for a Super User

As follows:

4. Start the database

Note: If you are not registered as a system service, you must manually start the service each time. Otherwise, pgadmin3 fails to connect to the database.

Pg_ctl-D d: \ postgresql-l logfile start

Shown as follows:

After it is started, A logfile file is generated under the main directory installed in the database: D: \ postgresql \ logfile

5. Register as a win8 System Service

Note: Only Administrators are required.

Pg_ctl register-N PostgreSQL-D: \ postgresql \ data

View the registered service: win + R in the pop-up dialog box, enter services. msc, as shown below:

Net start PostgreSQL to check whether the task is started: Enter tasklist in the command line

Netstat-an allows you to view all IP addresses that are connected to the local computer and uninstall the service. You also need administrator permissions.

1) pg_ctl unregister-N PostgreSQL (win8)

2) SC delete PostgreSQL (PostgreSQL)

6. Configure the pgAdmin3 Client

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

7. Database Connection successful

How can postgresql support remote login?

You only need to configure
Modify two files:

Postgresql. conf
Pg_mirror.conf

-----------------
For example, the ip address of the db server in the environment is 10.10.3.5,
The Client ip address is 10.10.3.5.

Add the following in the postgresql. conf file:
Listen_addresses = '*'

Add:
Host all 10.10.3.1/24 trust
24 indicates that the mask is 255.255.255.0, so it indicates that all IP addresses in this subnet are open.
You can access 10.10.3.5 on 10.10.3.5.

Run
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.