Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers. Closed 4 years ago. We don’t allow questions about professional server or networking-related infrastructure administration on Stack Overflow. You can edit the question so it’s on-topic for Stack Overflow. We don’t allow questions about general computing hardware and software on Stack Overflow. You can edit the question so it’s on-topic for Stack Overflow. The community reviewed whether to reopen this question last month and left it closed: Original close reason(s) were not resolved Improve this question
Somehow I've managed to completely bugger the install of postgresql on Ubuntu karmic. I want to start over from scratch, but when I "purge" the package with apt-get it still leaves traces behind such that the reinstall configuration doesn't run properly.
After I've done:
apt-get purge postgresql
apt-get install postgresql
It said
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) ...
I have a "/etc/postgresql" with nothing in it and "/etc/postgresql-common/" has a 'pg_upgradecluser.d' directory and root.crt and user_clusters files.
The /etc/passwd has a postgres user; the purge script doesn't appear to touch it. There's been a bunch of symptoms which I work through only to expose the next.
Right this second, when I run that command "pg_createcluster..." it complains that '/var/lib/postgresql/8.4/main/postgresql.conf does not exist', so I'll go find one of those but I'm sure that won't be the end of it.
Is there not some easy one-liner (or two) which will burn it completely and let me start over?
Option A
If your install isn't already damaged, you can drop unwanted PostgreSQL servers ("clusters") using pg_dropcluster
. Use that in preference to a full purge and reinstall if you just want to restart with a fresh PostgreSQL instance.
$ pg_lsclusters
Ver Cluster Port Status Owner Data directory Log file
11 main 5432 online postgres /var/lib/postgresql/11/main /var/log/postgresql/postgresql-11-main.log
$ sudo systemctl stop postgresql@11-main
$ sudo pg_dropcluster --stop 11 main
$ sudo pg_createcluster --start 11 main
Option B
If you really need to do a full purge and reinstall, first make sure PostgreSQL isn't running. ps -C postgres
should show no results.
Now run:
apt-get --purge remove postgresql\*
to remove everything PostgreSQL from your system. Just purging the postgres
package isn't enough since it's just an empty meta-package.
Once all PostgreSQL packages have been removed, run:
rm -r /etc/postgresql/
rm -r /etc/postgresql-common/
rm -r /var/lib/postgresql/
userdel -r postgres
groupdel postgres
You should now be able to:
apt-get install postgresql
or for a complete install:
apt-get install postgresql-8.4 postgresql-contrib-8.4 postgresql-doc-8.4
I had a similar situation: I needed to purge postgresql 9.1 on a debian wheezy ( I had previously migrated from 8.4 and I was getting errors ).
What I did:
First, I deleted config and database
$ sudo pg_dropcluster --stop 9.1 main
Then removed postgresql
$ sudo apt-get remove --purge postgresql postgresql-9.1
and then reinstalled
$ sudo apt-get install postgresql postgresql-9.1
In my case I noticed /etc/postgresql/9.1 was empty, and running service postgresql start
returned nothing
So, after more googling I got to this command:
$ sudo pg_createcluster 9.1 main
With that I could start the server, but now I was getting log-related errors. After more searching, I ended up changing permissions to the /var/log/postgresql directory
$ sudo chown root.postgres /var/log/postgresql
$ sudo chmod g+wx /var/log/postgresql
That fixed the issue, Hope this helps
Steps that worked for me on Ubuntu 8.04.2
to remove 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/
apt-get --purge remove postgresql\*
apt-get purge postgresql*
is enough.
I know an answer has already been provided, but dselect didn't work for me. Here is what worked to find the packages to remove:
# 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/
Finally, editing /etc/passwd and /etc/group
Following ae the steps i followed to uninstall and reinstall. Which worked for me.
First remove the installed postgres :-
sudo apt-get purge postgr* sudo apt-get autoremove
Then install 'synaptic':
sudo apt-get install synaptic sudo apt-get update
Then install postgres
sudo apt-get install postgresql postgresql-contrib
I just ran into the same issue for Ubuntu 13.04. These commands removed Postgres 9.1:
sudo apt-get purge postgresql
sudo apt-get autoremove postgresql
It occurs to me that perhaps only the second command is necessary, but from there I was able to install Postgres 9.2 (sudo apt-get install postgresql-9.2).
I was following the replies, When editing /etc/group I also deleted this line:
ssl-cert:x:112:postgres
then, when trying to install postgresql, I got this error
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)
Putting the "ssl-cert:x:112:postgres" line back in /etc/group seems to fix it (so I was able to install postgresql)
/etc/passwd
. never do that. Use the userdel
and groupdel
commands and you won't have that problem in future.
I was facing same problem in my ubuntu 16.04
but i fixed that problem and it's very simple just follow these step and you will be able to install postgresql 10 in your system :
Add this to your sources.list:
sudo vim /etc/apt/sources.list
deb http://ftp.de.debian.org/debian/ wheezy main non-free contrib
deb-src http://ftp.de.debian.org/debian/ wheezy main non-free contrib
after that add these link to your pgdg.list file if it's not there you have to create && add link && save it.
sudo vim /etc/apt/sources.list.d/pgdg.list
deb http://apt.postgresql.org/pub/repos/apt/ xenial-pgdg main
deb http://apt.postgresql.org/pub/repos/apt/ precise-pgdg main
then update your system
sudo apt-get update
sudo apt-get upgrade
and install that unmet dependencies :
apt-get install ssl-cert
that's it. now Install postgresql using these command
sudo apt-get install postgresql-10
Success story sharing
/etc/passwd
and/etc/group
in favour of saferuserdel
andgroupdel
. Also, rather than usingdselect
for hand-selection of packages, use an apt wildcard to match them reliably.pg_dropcluster
!! (Example Usage:pg_dropcluster --stop 9.1 main
)rm -r /var/log/postgresql
.