在windows下手动初始化PostgreSQL数据库教程

所属分类: 数据库 / PostgreSQL 阅读数: 142
收藏 0 赞 0 分享

环境:win7 64 sp1
PG:9.3.5

1、创建用户postgres,密码同样是postgres:

net user postgres postgres /add

2、在数据库根目录下建立data目录:

C:\Program Files\PostgreSQL\9.3>md data

3、去掉administrator对data目录的权限:

C:\Program Files\PostgreSQL\9.3>cacls data /e /t /r administrator

处理的目录: C:\Program Files\PostgreSQL\9.3\data
4、将data目录的权限赋给postgres用户:

C:\Program Files\PostgreSQL\9.3>cacls data /e /t /g postgres:C

处理的目录: C:\Program Files\PostgreSQL\9.3\data
5、用postgres用户打开cmd

C:\Program Files\PostgreSQL\9.3>runas /user:postgres cmd.exe

输入 postgres 的密码:
试图将 cmd.exe 作为用户 "SURE-PC\postgres" 启动...
6、进行初始化,初始化用户为postgres,字符集为utf8,locale为C:

C:\Program Files\PostgreSQL\9.3\bin>initdb.exe -D ../data -E utf8 --locale C -U
 postgres
The files belonging to this database system will be owned by user "postgres".
This user must also own the server process.
 
The database cluster will be initialized with locale "C".
The default text search configuration will be set to "english".
 
Data page checksums are disabled.
 
fixing permissions on existing directory ../data ... ok
creating subdirectories ... ok
selecting default max_connections ... 100
selecting default shared_buffers ... 128MB
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 collations ... not supported on this platform
creating conversions ... ok
creating dictionaries ... ok
setting privileges on built-in objects ... ok
creating information schema ... ok
loading PL/pgSQL server-side language ... ok
vacuuming database template1 ... ok
copying template1 to template0 ... ok
copying template1 to postgres ... ok
syncing data to disk ... ok
 
WARNING: enabling "trust" authentication for local connections
You can change this by editing pg_hba.conf or using the option -A, or
--auth-local and --auth-host, the next time you run initdb.
 
Success. You can now start the database server using:
 
  "postgres" -D "../data"
or
  "pg_ctl" -D "../data" -l logfile start
 
 
C:\Program Files\PostgreSQL\9.3\bin>


7、启动数据库,进入客户端:

C:\Program Files\PostgreSQL\9.3\bin>"pg_ctl" -D "../data" start
server starting
 
C:\Program Files\PostgreSQL\9.3\bin>LOG: database system was shut down at 2014-
09-18 10:19:54 HKT
LOG: autovacuum launcher started
 
C:\Program Files\PostgreSQL\9.3\bin>LOG: database system is ready to accept con
nections
 
C:\Program Files\PostgreSQL\9.3\bin>psql.exe
psql (9.3.5)
Type "help" for help.
 
postgres=#

更多精彩内容其他人还在看

详解PostgreSQL 语法中关键字的添加

这篇文章主要介绍了详解PostgreSQL 语法中关键字的添加的相关资料,这里说明下在parser语法解析模块添加关键字,需要的朋友可以参考下
收藏 0 赞 0 分享

在Ubuntu中安装Postgresql数据库的步骤详解

PostgreSQL 是一款强大的,开源的,对象关系型数据库系统。它支持所有的主流操作系统,包括 Linux、Unix(AIX、BSD、HP-UX,SGI IRIX、Mac OS、Solaris、Tru64) 以及 Windows 操作系统。本文给大家介绍了在Ubuntu中安装P
收藏 0 赞 0 分享

Ubuntu中卸载Postgresql出错的解决方法

这篇文章主要给大家介绍了关于在Ubuntu中卸载Postgresql出错的解决方法,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友们下面随着小编来一起学习学习吧。
收藏 0 赞 0 分享

PostgreSQL更新表时时间戳不会自动更新的解决方法

这篇文章主要为大家详细介绍了PostgreSQL更新表时时间戳不会自动更新的解决方法,具有一定的参考价值,感兴趣的小伙伴们可以参考一下
收藏 0 赞 0 分享

Abp.NHibernate连接PostgreSQl数据库的方法

这篇文章主要为大家详细介绍了Abp.NHibernate连接PostgreSQl数据库的方法,具有一定的参考价值,感兴趣的小伙伴们可以参考一下
收藏 0 赞 0 分享

PostgreSQL使用IP无法连接的解决方法

这篇文章主要介绍了PostgreSQL使用localhost可以连接/使用IP无法连接的问题解决,需要的朋友可以参考下
收藏 0 赞 0 分享

Postgresql开启远程访问的步骤全纪录

postgre一般默认为本地连接,不支持远程访问,所以如果要开启远程访问,需要更改安装文件的配置。下面这篇文章主要给大家介绍了关于Postgresql开启远程访问的相关资料,需要的朋友可以参考借鉴,下面来一起看看吧。
收藏 0 赞 0 分享

PostgreSQL中Slony-I同步复制部署教程

这篇文章主要给大家介绍了关于PostgreSQL中Slony-I同步复制部署的相关资料,文中通过示例代码介绍的非常详细,对大家学习或者使用PostgreSQL具有一定的参考学习价值,需要的朋友们下面随着小编来一起学习学习吧
收藏 0 赞 0 分享

PostgreSQL实战之启动恢复读取checkpoint记录失败的条件详解

这篇文章主要给大家介绍了关于PostgreSQL实战之启动恢复读取checkpoint记录失败的条件的相关资料,文中通过示例代码介绍的非常详细,需要的朋友可以参考借鉴,下面随着小编来一起学习学习吧
收藏 0 赞 0 分享

PostgreSQL存储过程用法实战详解

这篇文章主要介绍了PostgreSQL存储过程用法,结合具体实例详细分析了PostgreSQL数据库存储过程的定义、使用方法及相关操作注意事项,并附带一个完整实例供大家参考,需要的朋友可以参考下
收藏 0 赞 0 分享
查看更多