Windows下手動安裝PostgreSQL實踐

來源:互聯網
上載者:User

一、基本安裝

1、下載postgresql-8.3.3-2-binaries-no-installer.zip

2、解壓postgresql-8.3.3-2-binaries-no-installer.zip到C:\

3、詳細安裝步驟如下:

 

 

 

(在超級使用者權限下執行命令)

C:\>cd pgsql

C:\pgsql>dir
 磁碟機 C 中的卷是 winxp
 卷的序號是 382E-2B62

 C:\pgsql 的目錄

2008-09-18  18:48    <DIR>          .
2008-09-18  18:48    <DIR>          ..
2008-09-18  18:48    <DIR>          bin
2008-09-18  18:48    <DIR>          doc
2008-09-18  18:48    <DIR>          include
2008-09-18  18:48    <DIR>          lib
2008-09-18  18:48    <DIR>          share
2008-09-18  18:48    <DIR>          symbols
               0 個檔案              0 位元組
               8 個目錄  1,241,993,216 可用位元組

C:\pgsql>net user postgres password /add /expires:never /passwordchg:no
命令成功完成。

C:\pgsql>net localgroup users postgres /del
命令成功完成。

C:\pgsql>cacls . /T /E /P postgres:R

處理的檔案: C:\pgsql\symbols\vacuumdb.pdb
處理的檔案: C:\pgsql\symbols\vacuumlo.pdb
處理的檔案: C:\pgsql\symbols\zic.pdb
處理的檔案: C:\pgsql\symbols\_int.pdb

C:\pgsql>runas /noprofile /env /user:postgres "cmd"
輸入 postgres 的密碼:password
試圖將 cmd 作為使用者 "FMX-7E918992334\postgres" 啟動...

C:\pgsql>

 

 

(在postgres使用者權限下執行命令)

Microsoft Windows XP [版本 5.1.2600]
(C) 著作權 1985-2001 Microsoft Corp.

C:\pgsql>bin\initdb.exe -D data -E EUC_CN --locale=C -A md5 -U admin -W
屬於此資料庫系統的檔案宿主為使用者 "postgres".
此使用者也必須為伺服器處理序的宿主.
資料庫簇將帶有 locale C 初始化.
The default text search configuration will be set to "english".

建立目錄 data ... 成功
creating subdirectories ... 成功
選擇預設最大聯結數 (max_connections) ... 100
selecting default shared_buffers/max_fsm_pages ... 32MB/204800
建立設定檔 ... 成功
在 data/base/1 中建立 template1 資料庫 ... 成功
initializing pg_authid ... 成功
輸入新的超級使用者口令:adminpassword
再輸入一遍:adminpassword
設定口令 ... 成功
initializing dependencies ... 成功
建立系統檢視表 ... 成功
loading system objects' descriptions ... 成功
建立字元集轉換 ... 成功
creating dictionaries ... 成功
對內建對象設定許可權 ... 成功
建立提示模式 ... 成功
清理資料庫 template1 ... 成功
拷貝 template1 到 template0 ... 成功
copying template1 to postgres ... 成功

Success. You can now start the database server using:

    "bin\postgres" -D "data"
or
    "bin\pg_ctl" -D "data" -l logfile start

C:\pgsql>bin\pg_ctl.exe -D data -l logfile start
server starting

C:\pgsql>bin\pg_ctl.exe -D data stop
waiting for server to shut down.... 完成
server stopped

C:\pgsql>

 

 

 

 

二、註解:

1、net localgroup users postgres /del

把postgres使用者從users組中刪除,這樣postgres就不能登陸了,更安全。

 

2、用pgAdmin III串連資料庫時用admin使用者,密碼為adminpassword。

 

三、作為Windows服務自動啟動

(在超級使用者權限下執行命令)

註冊服務:

C:\pgsql>bin\pg_ctl register -N PostgreSQL  -D c:\pgsql\data

登出服務:

C:\pgsql>bin\pg_ctl unregister -N PostgreSQL

啟動服務:

C:\pgsql>sc start PostgreSQL

停止服務:

C:\pgsql>sc stop PostgreSQL

 

 

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.