The solution to the problem of uninstalling Postgresql in Ubuntu

  • 2020-05-06 11:56:50
  • OfStack

Preface to

Recently, there was an error in the unloading of PostgreSQL database, but I can only solve it step by step by troubleshooting analysis. The following process will be Shared, for the friends who also encounter this problem reference learning, the following words do not say, to see a detailed introduction together.

error output:


Removing postgresql-9.1 (9.1.18-0ubuntu0.12.04) ...
/var/lib/dpkg/info/postgresql-9.1.prerm: 9: .: Can't open /usr/share/postgresql-common/maintscripts-functions
dpkg: error processing package postgresql-9.1 (--remove):
  The child process   Has been installed  pre-removal  The script   An error number is returned  2
dpkg: postgresql-client-9.1: dependency problems, but removing anyway as you requested:
 postgresql-9.1  Depends on the  postgresql-client-9.1.

Removing postgresql-client-9.1 (9.1.18-0ubuntu0.12.04) ...
/var/lib/dpkg/info/postgresql-client-9.1.prerm: 10: .: Can't open /usr/share/postgresql-common/maintscripts-functions
dpkg: error processing package postgresql-client-9.1 (--remove):
  The child process   Has been installed  pre-removal  The script   An error number is returned  2
/var/lib/dpkg/info/postgresql-client-9.1.postinst: 7: .: Can't open /usr/share/postgresql-common/maintscripts-functions
dpkg : error in cleaning :
  The child process   Has been installed  post-installation  The script   An error number is returned  2
 Error occurred during processing: 
 postgresql-9.1
 postgresql-client-9.1
E: Sub-process /usr/bin/dpkg returned an error code (1)

resolution process

Use the following command:


sudo rm -r /var/lib/dpkg/info/postgresq*

And then the


sudo apt-get autoremove postgresql*

Finally:


dpkg : warning: files list file for package 'postgresql-9.1' missing; assuming package has no files currently installed
dpkg : warning: files list file for package 'postgresql-client-9.1' missing; assuming package has no files currently installed
( Reading database  ...  The system is currently installed  146453  Two files and directories. )
Removing postgresql-9.1 (9.1.18-0ubuntu0.12.04) ...
Removing postgresql-client-9.1 (9.1.18-0ubuntu0.12.04) ...

In fact, it seems that the first command deleted the metadata information of dpkg about postgresql, and then when autoremove is used, dpkg thinks postgresql is not installed, and then prompts that the uninstall is successful.

summary


Related articles: