注意下載的是二進制版,不是帶Windows Installer的。
http://www.enterprisedb.com/products-services-training/pgbindownload
x86下載http://get.enterprisedb.com/postgresql/postgresql-9.2.4-1-windows-binaries.zip
x64下載http://get.enterprisedb.com/postgresql/postgresql-9.2.4-1-windows-x64-binaries.zip
執(zhí)行下列步驟前,暫作以下假定:
PostgreSQL擬裝在d:\postgresql
數(shù)據(jù)庫以后擬存放在d:\postgresql\data
首先下載postgresql-9.2.4-1-windows-x64-binaries.zip最新版待用,下列步驟達到手工安裝好PostgreSQL,初始化數(shù)據(jù)庫,將PostgreSQL注冊為服務(wù)。
1、PostgreSQL.zip解壓至d:\postgresql后,創(chuàng)建一個data目錄;

2. 設(shè)置環(huán)境變量,編輯批處理文件 配置環(huán)境變量.vbs(永久生效)
a) 內(nèi)容如下
on error resume next
set sysenv=CreateObject("WScript.Shell").Environment("system") '系統(tǒng)環(huán)境變量的數(shù)組對象
Path = CreateObject("Scripting.FileSystemObject").GetFolder(".").Path
'添加變量
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環(huán)境變量安裝成功!不需要重新啟動計算機?。?
b) 執(zhí)行如下:


3、在空白處按住shift點擊鼠標(biāo)右鍵,新開一個cmd窗口,并cd 至d:\postgresql\bin ;
4. 初始化并創(chuàng)建數(shù)據(jù)庫(一次即可)
initdb.exe -D d:\postgresql\data -E UTF-8 --locale=chs -U postgres -W
-D :指定數(shù)據(jù)庫簇的存儲目錄E:\pgsql\data
-E :指定DB的超級用戶的用戶名postgres
--locale:關(guān)于區(qū)域設(shè)置(chinese-simplified-china)
-U :默認(rèn)編碼格式chs
-W :為超級用戶指定密碼的提示
如下:

4. 啟動數(shù)據(jù)庫
注:若未注冊為系統(tǒng)服務(wù),則需每次手動啟動,否則pgadmin3連接數(shù)據(jù)庫失敗
pg_ctl -D d:\postgresql -l logfile start
顯示如下:

啟動后,在數(shù)據(jù)庫安裝的主目錄下生成一個logfile文件:D:\postgresql\logfile
5. 注冊為win8系統(tǒng)服務(wù)
注:需管理員權(quán)限方可
pg_ctl register -N PostgreSQL -D D:\postgresql\data
查看已經(jīng)注冊的服務(wù):win+R在彈出的運行框中,輸入:services.msc,如下:

net start PostgreSQL 查看是否啟動:命令行下輸入tasklist

netstat –an 可以查看所有和本地計算機建立連接的IP 卸載服務(wù):同樣需要管理員權(quán)限,兩種方式
1) pg_ctl unregister –N PostgreSQL (win8)
2) sc delete PostgreSQL (PostgreSQL)
6. 配置pgAdmin3客戶端
目錄為D:\postgresql\bin\ pgAdmin3,雙擊,配置

7. 連接數(shù)據(jù)庫成功

如何讓postgresql支持遠(yuǎn)程登錄呢?
只需要在服務(wù)器端配置
修改兩個文件:
postgresql.conf
pg_hba.conf
-----------------
比如環(huán)境中db server ip為10.10.3.5,
客戶端的ip為10.10.3.5
在postgresql.conf文件添加:
listen_addresses = '*'
在pg_hba.conf文件添加:
host all all 10.10.3.1/24 trust
24表示掩碼為255.255.255.0,所以表示對這個子網(wǎng)的所有IP開放了。
就可以在10.10.3.5上訪問10.10.3.5了。
完成后執(zhí)行一下
C:\Windows\System32>net stop PostgreSQL
C:\Windows\System32>net start PostgreSQL

您可能感興趣的文章:- PostgreSQL安裝、配置及簡單使用方法
- CentOS中運行PostgreSQL需要修改的內(nèi)核參數(shù)及配置腳本分享
- Debian中PostgreSQL數(shù)據(jù)庫安裝配置實例
- postgresql減少wal日志生成量的操作
- Postgresql的日志配置教程詳解