1.將下載的壓縮包解壓,我是解壓在D:postgreSQLpgsql中。
2.設置環(huán)境變量如下:
set PGHOME=D:postgreSQLpgsql
set PGDATA=%PGHOME%data
set PGLIB=%PGHOME%lib
set PGHOST=localhost
set PATH=%PGHOME%in;%PATH%
3.創(chuàng)建數(shù)據(jù)庫,利用pgsqlin目錄下的initdb.exe命令,我用的格式如下:
view sourceprint?1 initdb --locale=CHS -E UTF8 -D "myPostgre" -U postgre –W postgre
view sourceprint?1 關于initdb的詳細參數(shù),可以用initdb --help來查看。
view sourceprint?1 若是執(zhí)行成功,有如下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
上面紅色的地方需要輸入數(shù)據(jù)庫超級用戶的密碼。
4.成功安裝后,在windows中添加用戶 postgre,該用戶就是之前在initdb命令中-U 后的用戶名。
5.啟動數(shù)據(jù)庫和停止數(shù)據(jù)庫的命令為:
pg_ctl -D "myPostgre" start
pg_ctl -D "myPostgre" stop
然后就可以開始postgresql的學習之旅了。
歡迎網(wǎng)友在網(wǎng)投稿或反饋意見。