下载postgresql-8.4.1-1-windows-binaries.zip
解压解压到C:\Program Files\postgresql目录
【创建数据文件及配置文件】
进入C:\Program Files\postgresql\目录,创建data目录,用于存放数据文件。
打开cmd,执行:bin\initdb --locale=CHS -E UTF8 -D data,创建数据文件及配置文件。输出如下:
------------------------------------------------------------------------------------------------
C:\Program Files\postgresql>bin\initdb --locale=CHS -E UTF8 -D data
The files belonging to this database system will be owned by user "bbn".
This user must also own the server process.
The database cluster will be initialized with locale CHS.
initdb: could not find suitable text search configuration for locale CHS
The default text search configuration will be set to "simple".
fixing permissions on existing directory data ... ok
creating subdirectories ... ok
selecting default max_connections ... 100
selecting default shared_buffers ... 32MB
creating configuration files ... ok
creating template1 database in 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:
"bin\postgres" -D "data"
or
"bin\pg_ctl" -D "data" -l logfile start
------------------------------------------------------------------------------------------------
【启动数据库】
------------------------------------------------------------------------------------------------
C:\Program Files\postgresql>bin\postgres -D data
LOG: database system was shut down at 2009-09-12 19:44:25 HKT
LOG: database system is ready to accept connections
LOG: autovacuum launcher started
------------------------------------------------------------------------------------------------
【停止数据库】
------------------------------------------------------------------------------------------------
C:\Program Files\postgresql>bin\pg_ctl stop -D data
waiting for server to shut down.... done
server stopped
此时启动数据库的cmd窗口输出:
C:\Program Files\postgresql>bin\postgres -D data
LOG: database system was shut down at 2009-09-12 19:44:25 HKT
LOG: database system is ready to accept connections
LOG: autovacuum launcher started
LOG: received smart shutdown request
LOG: autovacuum launcher shutting down
LOG: shutting down
LOG: database system is shut down
------------------------------------------------------------------------------------------------
【创建并连接数据库】
C:\Program Files\postgresql>bin\createdb test
C:\Program Files\postgresql>bin\psql -h localhost -w -d test
psql (8.4.1)
Type "help" for help.
test=#
test=# help
You are using psql, the command-line interface to PostgreSQL.
Type: \copyright for distribution terms
\h for help with SQL commands
\? for help with psql commands
\g or terminate with semicolon to execute query
\q to quit
test=# \q
【注册windows服务】
使用"pg_ctl register -N 'PostgreSQL Server' -U postgres -P 123456 -D 'C:\pgsql\data'"来注册服务;
没有评论:
发表评论