简体   繁体   中英

Cannot reinstall postgresql - apt-get dependency errors

I previously could install postgresql but then I uninstalled and installed it again, now if I try:

sudo apt-get update
sudo apt-get install postgresql postgresql-contrib

This will appear:

Reading package lists... Done
Building dependency tree       
Reading state information... Done
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:

The following packages have unmet dependencies:
 postgresql : Depends: postgresql-9.4 but it is not going to be installed
 postgresql-contrib : Depends: postgresql-contrib-9.4 but it is not going to be installed
E: Unable to correct problems, you have held broken packages.

What's wrong here?

I want to remodel starting from scratch. So what I did before:

sudo apt-get --purge remove postgresql
sudo rm -rf /var/lib/postgresql/ 
sudo rm -rf /var/log/postgresql/ 
sudo rm -rf /etc/postgresql/

You may have a broken database. Try: sudo apt-get --fix-broken

Alternatively, it may be that there are files left behind that are conflicting with version 9.4 of postgresql. If you can, install the version of postgresql you had before, then, using dpkg-query -L <package_name> , you can see what files were installed and what you may have left behind.

run the following.

sudo apt install aptitude && sudo aptitude install postgresql postgresql-contrib

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM