1.将下载的压缩包解压,我是解压在D:postgreSQLpgsql中。
2.设置环境变量如下:
set PGHOME=D:postgreSQLpgsql
set PGDATA=%PGHOME%data
set PGLIB=%PGHOME%lib
set PGHOST=localhost
set PATH=%PGHOME%in;%PATH%
3.创建数据库,利用pgsqlin目录下的initdb.exe命令,我用的格式如下:
view sourceprint?1 initdb --locale=CHS -E UTF8 -D "myPostgre" -U postgre –W postgre
view sourceprint?1 关于initdb的详细参数,可以用initdb --help来查看。
view sourceprint?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.启动数据库和停止数据库的命令为:
pg_ctl -D "myPostgre" start
pg_ctl -D "myPostgre" stop
然后就可以开始postgresql的学习之旅了。
欢迎网友在网投稿或反馈意见。