大网数据广告活动
服务器运维问答

postgresql installation : initdb data directory not empty?

· 52CE 我爱测

I am trying to create the postgresql database. When I install PostgreSQL, I gave this command: sudo yum install postgresql postgresql-server and later I modified the config file: sudo vim /var/lib/pgsql/data/pg_hba.conf and modif…

问题原文

原帖链接 · sridhar · CC BY-SA 3.0

I am trying to create the postgresql database.

When I install PostgreSQL, I gave this command:

sudo yum install postgresql postgresql-server

and later I modified the config file:

sudo vim /var/lib/pgsql/data/pg_hba.conf

and modified as

local   all         all                               trust
host    all         all         127.0.0.1/32          trust
host    all         all         ::1/128               trust
host    all         all         0.0.0.0/0             md5

While I am trying to startup the postgresql service:

sudo service postgresql initdb

> Data directory is not empty!                               [FAILED]

sudo chkconfig postgresql on

sudo service postgresql start

Starting postgresql service:                               [  OK  ]

What is caused these errors and how do I fix them?

已采纳解答

原帖链接 · Jenny D · CC BY-SA 3.0

Initdb should only be run once. It will create the directory where you'll keep the config files and (usually) the actual database. You've obviously already done that already; otherwrise there wouldn't be any pg_hba.conf for you to edit.

So, just don't run postgresql initdb again, unless you are doing a complete reinstall.

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2013-05-08)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 3.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。