Postgresql在Windows下的解壓安裝


1.將下載的壓縮包解壓,我是解壓在D:\postgreSQL\pgsql中。

2.設置環境變量如下:

    set PGHOME=D:\postgreSQL\pgsql
    set PGDATA=%PGHOME%\data
    set PGLIB=%PGHOME%\lib
    set PGHOST=localhost
    set PATH=%PGHOME%\bin;%PATH%

3.創建數據庫,利用pgsql\bin目錄下的initdb.exe命令,我用的格式如下:

?
1
initdb --locale=CHS -E UTF8 -D "myPostgre" -U postgre –W postgre

如果對命令不熟悉可以用如下的命令進行初始化,最后一個參數是自己創建的數據目錄:

initdb.exe -U postgres -W --locale=C -E UTF8 -D C:\Users\user\Desktop\Hadoop\pgsql\data

?
1
關於initdb的詳細參數,可以用initdb --help來查看。
?
1
若是執行成功,有如下log信息:

creating directory postgre ... ok
creating subdirectories ... ok
selecting default max_connections ... 100
selecting default shared_buffers ... 32MB
creating configuration files ... ok
creating template1 database in postgre/base/1 ... ok
initializing pg_authid ... ok
Enter new superuser password:
Enter it again:

setting password ... ok
initializing dependencies ... ok
creating system views ... ok
loading system objects' descriptions ... ok
creating conversions ... ok
creating dictionaries ... ok
setting privileges on built-in objects ... ok
creating information schema ... ok
vacuuming database template1 ... ok
copying template1 to template0 ... ok
copying template1 to postgres ... ok

上面紅色的地方需要輸入數據庫超級用戶的密碼。

4.成功安裝后,在windows中添加用戶 postgre,該用戶就是之前在initdb命令中-U 后的用戶名。

5.啟動數據庫和停止數據庫的命令為:

?
1
2
pg_ctl -D "myPostgre" start
pg_ctl -D "myPostgre" stop 
?
1
然后就可以開始postgresql的學習之旅了:)。
?
1
我也是剛開始學習postgresql,主要是想利用其空間數據庫的功能來完成一些GIS方面的應用。
?
1
希望能和大家多交流交流,同時能得到高手的指教!
原文地址:https://www.cnblogs.com/wang_yb/archive/2010/04/25/1720787.html


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM