How to download and configure Postgresql in Windows, windowspostgresql
Note that the download is a binary version, not a Windows Installer, or a green version.
Http://www.enterprisedb.com/products-services-training/pgbindownload
X86 download: postgresqwindows
X64 download: postgresqwindowsx64
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 Environment Variables, Edit the environment variable for 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
Note: because there is no slsadmin (Custom User), an error is reported. Use the created ipvs user to log on. After logging on, use this account to create another account.
7. Database Connection successful
How can postgresql support remote login?
By default, the remote access to postgresql is unsuccessful. To allow remote access, you need to modify two configuration files as follows:
1. postgresql. conf
Set the value of listen_addresses in this file to "*". In Windows 9.0, this configuration is already "*" and does not need to be modified.
2. pg_cmd.conf
Add the following configuration under the host all 127.0.0.1/32 md5 line after the ipv4 configuration in the configuration file, or directly change this line to the following configuration
Host all 0.0.0.0/0 md5
If you do not want to allow remote access from all IP addresses, you can set 0.0.0.0 in the preceding configuration item to a specific IP address.
Note: The value of listen_addresses is set to "*", which is commented out by default. If this parameter is not commented out, it cannot be accessed, use the built-in pgadmin tool to modify the configuration.
The above is all the content of this article. I hope it will be helpful for your learning and support for helping customers.