initdb
是一个服务器实用程序,用于初始化新的PostgreSQL集群的数据目录。
initdb
一直存在于PostgreSQL中。
更改历史记录
- PostgreSQL 17
- PostgreSQL 16
- PostgreSQL 15
- PostgreSQL 14
- PostgreSQL 11
- PostgreSQL 10
- PostgreSQL 9.6
- 通过仅对引导后步骤使用一个后端来加速 (提交 c4a8812c)
- PostgreSQL 9.4
- 现在对不正确的语言环境设置抛出错误,而不是静默回退到默认设置 (提交 31a26323)
- PostgreSQL 9.3
- PostgreSQL 9.2
- 识别服务器时区并将值写入
postgresql.conf
(提交 ca4af308) - 添加了选项
--auth-local
和--auth-host
(提交 8a02339e)
- 识别服务器时区并将值写入
- PostgreSQL 9.0
- PostgreSQL 8.3
pg_xlog
目录的位置现在可以使用选项-X
/--xlogdir
指定;PostgreSQL 10 及更高版本:-X
/--waldir
(提交 c3578a68)
- PostgreSQL 8.2
- PostgreSQL 8.1
- 默认情况下创建一个名为
postgres
的数据库 (提交 6f7fc0ba)
- 默认情况下创建一个名为
- PostgreSQL 8.0
- PostgreSQL 7.1
- initdb排序规则存储在pg_control中,以防止更改排序规则
- PostgreSQL 7.0
- 添加了交互式密码提示 (提交 2a1bfbce)
示例
initdb
的基本用法示例
$ initdb -D /var/lib/pgsql 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 database encoding has accordingly been set to "SQL_ASCII". The default text search configuration will be set to "english". Data page checksums are disabled. fixing permissions on existing directory /var/lib/pgsql ... ok creating subdirectories ... ok selecting default max_connections ... 100 selecting default shared_buffers ... 128MB selecting default timezone ... UTC selecting dynamic shared memory implementation ... posix creating configuration files ... ok running bootstrap script ... ok performing post-bootstrap initialization ... 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: pg_ctl -D /var/lib/pgsql -l logfile start
参考文献
- PostgreSQL文档: initdb