不知怎的,我已经设法在Ubuntu上完全安装了postgresql。我想从头开始,但是当我用apt-get“清除”包时,它仍然会留下痕迹,导致重新安装配置不能正常运行。

完成之后:

apt-get purge postgresql
apt-get install postgresql

它说

Setting up postgresql-8.4 (8.4.3-0ubuntu9.10.1) ...
Configuring already existing cluster (configuration: /etc/postgresql/8.4/main, data: /var/lib/postgresql/8.4/main, owner: 108:112)
Error: move_conffile: required configuration file     /var/lib/postgresql/8.4/main/postgresql.conf does not exist
Error: could not create default cluster. Please create it manually with

  pg_createcluster 8.4 main --start

or a similar command (see 'man pg_createcluster').
update-alternatives: using /usr/share/postgresql/8.4/man/man1/postmaster.1.gz to provide /usr/share/man/man1/postmaster.1.gz (postmaster.1.gz) in auto mode.

Setting up postgresql (8.4.3-0ubuntu9.10.1) ...

我有一个“/etc/postgresql”里面什么都没有,“/etc/postgresql-common/”有一个“pg_upgradecluser”。目录和根目录。CRT和user_clusters文件。

/etc/passwd有一个postgres用户;清除脚本似乎没有触及它。有一堆症状我都克服了结果又暴露了下一个。

就在这一秒,当我运行命令“pg_createcluster…”它会抱怨“/var/lib/postgresql/8.4/main/postgresql.conf不存在”,所以我会去找其中一个,但我相信这不会是它的结束。

难道就没有一些简单的一行(或两个)语句可以让我从头开始吗?


当前回答

apt-get purge postgresql*

就足够了。

其他回答

apt-get purge postgresql*

就足够了。

以下是我卸载和重新安装的步骤。这对我很管用。

首先删除已安装的postgres:-

Sudo apt-get清除postgr* Sudo apt-get自动删除

然后安装synaptic:

Sudo apt-get安装突触 Sudo apt-get update

然后安装postgres

安装postgresql postgresql-contrib

我在Ubuntu 8.04.2上删除postgres 8.3的步骤

List All Postgres related packages dpkg -l | grep postgres ii postgresql 8.3.17-0ubuntu0.8.04.1 object-relational SQL database (latest versi ii postgresql-8.3 8.3.9-0ubuntu8.04 object-relational SQL database, version 8.3 ii postgresql-client 8.3.9-0ubuntu8.04 front-end programs for PostgreSQL (latest ve ii postgresql-client-8.3 8.3.9-0ubuntu8.04 front-end programs for PostgreSQL 8.3 ii postgresql-client-common 87ubuntu2 manager for multiple PostgreSQL client versi ii postgresql-common 87ubuntu2 PostgreSQL database-cluster manager ii postgresql-contrib 8.3.9-0ubuntu8.04 additional facilities for PostgreSQL (latest ii postgresql-contrib-8.3 8.3.9-0ubuntu8.04 additional facilities for PostgreSQL Remove all above listed sudo apt-get --purge remove postgresql postgresql-8.3 postgresql-client postgresql-client-8.3 postgresql-client-common postgresql-common postgresql-contrib postgresql-contrib-8.3 Remove the following folders sudo rm -rf /var/lib/postgresql/ sudo rm -rf /var/log/postgresql/ sudo rm -rf /etc/postgresql/

我在看回复 当编辑/etc/group时,我也删除了这一行:

ssl-cert:x:112:postgres

然后,当我试图安装postgresql时,我得到了这个错误

Preconfiguring packages ...
dpkg: unrecoverable fatal error, aborting:
 syntax error: unknown group 'ssl-cert' in statoverride file
E: Sub-process /usr/bin/dpkg returned an error code (2)

将“ssl-cert:x:112:postgres”行放回/etc/group中似乎可以修复它(所以我能够安装postgresql)

我知道已经提供了一个答案,但dselect对我不起作用。以下是找到要删除的包的方法:

# search postgr  | grep ^i
i   postgresql                      - object-relational SQL database (supported 
i A postgresql-8.4                  - object-relational SQL database, version 8.
i A postgresql-client-8.4           - front-end programs for PostgreSQL 8.4     
i A postgresql-client-common        - manager for multiple PostgreSQL client ver
i A postgresql-common               - PostgreSQL database-cluster manager       

# aptitude purge postgresql-8.4 postgresql-client-8.4 postgresql-client-common postgresql-common postgresql

rm -r /etc/postgresql/
rm -r /etc/postgresql-common/
rm -r /var/lib/postgresql/

最后,编辑/etc/passwd和/etc/group