### [postgresql在windows(包括win7)下的安裝配置](http://deepfuture.iteye.com/blog/587477)**
[Windows](http://www.iteye.com/blogs/tag/Windows)[PostgreSQL](http://www.iteye.com/blogs/tag/PostgreSQL)[配置管理](http://www.iteye.com/blogs/tag/%E9%85%8D%E7%BD%AE%E7%AE%A1%E7%90%86)[SQL Server](http://www.iteye.com/blogs/tag/SQL%20Server)[C](http://www.iteye.com/blogs/tag/C)?
?
聲明:本PostgreSQl實用指南系列為劉興(http://deepfuture.iteye.com/)原創,未經筆者授權,任何人和機構不能轉載
首先,以下是常用命令:
③ initdb 初始化 數據庫。?
④ pg_ctl start 啟動數據庫?
⑤ pg_ctl stop 停止數據庫?
⑥ post_svc -install 建立windows nt 服務(需要設置系統環境變量)?
⑦ post_svc -remove 刪除 windows nt 服務?
⑧ 使用"createdb 庫名" 新建數據庫?
⑨ 使用"createuser 用戶名"創建數據庫帳號?
⑩ 使用"psql -h localhost -d 庫名- U 用戶名"進入數據庫
接著來講解:
一、下載postgresql for windows
[http://www.enterprisedb.com/products/pgbindownload.do](http://www.enterprisedb.com/products/pgbindownload.do)
免安裝的,直接解壓到硬盤的一個目錄下。筆者在d:\pgsql
二、設置環境變量,可以把以下內容寫成一個BAT
set PGHOME=d:\pgsql
set PATH=%PGHOME%\bin;%path%?
set PGHOST=localhost?
set PGLIB=%PGHOME%\lib?
set PGDATA=%PGHOME%\data
筆者把它們寫成了inst.bat
D:\pgsql>inst
D:\pgsql>set PGHOME=d:\pgsql
D:\pgsql>set PATH=d:\pgsql\bin;d:\pgsql\bin;d:\pgsql\bin;C:\Windows\system32;C:\
Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\
Program Files\Common Files\Thunder Network\KanKan\Codecs;C:\Program Files\Micros
oft SQL Server\90\Tools\binn\;d:\MATLAB7\bin\win32;
D:\pgsql>set PGHOST=localhost
D:\pgsql>set PGLIB=d:\pgsql\lib
D:\pgsql>set PGDATA=d:\pgsql\data
三、初始化數據庫
D:\pgsql>initdb --locale=C
The files belonging to this database system will be owned by user "Administrator
".
This user must also own the server process.
The database cluster will be initialized with locale C.
The default database encoding has accordingly been set to SQL_ASCII.
The default text search configuration will be set to "english".
fixing permissions on existing directory d:/pgsql/data ... ok
creating subdirectories ... ok
selecting default max_connections ... 100
selecting default shared_buffers ... 32MB
creating configuration files ... ok
creating template1 database in d:/pgsql/data/base/1 ... ok
initializing pg_authid ... 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
WARNING: enabling "trust" authentication for local connections
You can change this by editing pg_hba.conf or using the -A option the
next time you run initdb.
Success. You can now start the database server using:
??? "postgres" -D "d:/pgsql/data"
or
??? "pg_ctl" -D "d:/pgsql/data" -l logfile start
四、啟動
D:\pgsql>pg_ctl start
五、重新開一個MSDOS窗口
創建數據庫,以mydb為例
D:\pgsql>createdb -h 127.0.0.1 mydb
創建用戶
D:\pgsql>createuser -h 127.0.0.1 deepfuture
Shall the new role be a superuser? (y/n) y
D:\pgsql>
D:\pgsql>
六、啟動圖形界面開始管理
啟動pgAdmin3.exe程序進行配置(在BIN目錄下)

成功
?

?
?
- 數據表
- 模式Schema
- 表的繼承和分區
- 常用數據類型
- 函數和操作符-一
- 函數和操作符-二
- 函數和操作符-三
- 索引
- 事物隔離
- 性能提升技巧
- 服務器配置
- 角色和權限
- 數據庫管理
- 數據庫維護
- 系統表
- 系統視圖
- SQL語言函數
- PL-pgSQL過程語言
- PostgreSQL 序列(SEQUENCE)
- PostgreSQL的時間-日期函數使用
- PostgreSQL 查看數據庫,索引,表,表空間大小
- 用以查詢某表的詳細 包含表字段的注釋信息
- PostgreSQL 系統表查看系統信息
- postgre存儲過程簡單實用方法
- PostgreSQL實用日常維護SQL
- PostgreSQL的時間函數使用整理
- 命令
- pg_ctl控制服務器
- initdb 初始化數據庫簇
- createdb創建數據庫
- dropdb 刪除數據庫
- createuser創建用戶
- dropuser 刪除用戶
- psql交互式工具
- psql命令手冊
- pg_dump 數據庫轉儲
- pg_restore恢復數據庫
- vacuumdb 清理優化數據庫
- reindexdb 數據庫重創索引
- createlang 安裝過程語言
- droplang 刪除過程語言
- pg_upgrade 升級數據庫簇
- 調試存儲過程
- 客戶端命令-一
- 客戶端命令-二
- 使用技巧
- PostgreSQL刪除重復數據
- postgresql 小技巧
- PostgreSQL的10進制與16進制互轉
- PostgreSQL的漢字轉拼音
- Postgres重復數據的更新一例
- PostgreSQL使用with一例
- PostgreSQL在函數內返回returning
- PostgreSQL中的group_concat使用
- PostgreSQL數據庫切割和組合字段函數
- postgresql重復數據的刪除
- PostgreSQL的遞歸查詢(with recursive)
- PostgreSQL函數如何返回數據集
- PostgreSQL分區表(Table Partitioning)應用 - David_Tang - 博客園
- PostgreSQL: function 返回結果集多列和單列的例子
- 利用pgAgent創建定時任務
- 淺談 PostgreSQL 類型轉換類似Oracle
- postgresql在windows(包括win7)下的安裝配置
- PostgreSQL簡介、安裝、用戶管理、啟動關閉、創建刪除數據庫 (2010-11-08 12-52-51)轉載▼標簽: 雜談分類: PostgreSQL
- PostgreSQL的generate_series函數應用
- PostgreSQL 8.3.1 全文檢索(Full Text Search)
- postgresql record 使用
- 備份恢復
- PostgreSQL基于時間點恢復(PITR)
- Postgresql基于時間點恢復PITR案例(二)
- Postgres邏輯備份腳本
- Postgres invalid command \N數據恢復處理