Preface
I have recently made an error in uninstalling the PostgreSQL database. I have no choice but to investigate, analyze and solve it step by step. I will share the solution process below and give reference to friends who also encounter this problem. I won’t say much below, let’s take a look at the detailed introduction together.
Error output:
Removing postgresql-9.1 (9.1.18-0ubuntu0.12.04) ... /var/lib/dpkg/info/postgresql-9.: 9: .: Can't open /usr/share/postgresql-common/maintscripts-functions dpkg: error processing package postgresql-9.1 (--remove): Subprocess Installed pre-removal script The error number was returned 2 dpkg: postgresql-client-9.1: dependency problems, but removing anyway as you requested: postgresql-9.1 Depend on postgresql-client-9.1. Removing postgresql-client-9.1 (9.1.18-0ubuntu0.12.04) ... /var/lib/dpkg/info/postgresql-client-9.: 10: .: Can't open /usr/share/postgresql-common/maintscripts-functions dpkg: error processing package postgresql-client-9.1 (--remove): Subprocess Installed pre-removal script The error number was returned 2 /var/lib/dpkg/info/postgresql-client-9.: 7: .: Can't open /usr/share/postgresql-common/maintscripts-functions dpkg:An error occurred while cleaning: Subprocess Installed post-installation script The error number was returned 2 An error occurred while processing: postgresql-9.1 postgresql-client-9.1 E: Sub-process /usr/bin/dpkg returned an error code (1)
Solution process
Use the following command:
sudo rm -r /var/lib/dpkg/info/postgresq*
Then
sudo apt-get autoremove postgresql*
Finally, you can see:
dpkg:warn:files list file for package 'postgresql-9.1' missing; assuming package has no files currently installed dpkg:warn:files list file for package 'postgresql-client-9.1' missing; assuming package has no files currently installed (Reading the database ... The system is currently installed 146453 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 feels like the first command deleted the metadata information of dpkg about postgresql. When using the autoremove command, dpkg thought postgresql was not installed, and then prompted that the uninstallation was successful.
Summarize
The above is the entire content of this article. I hope the content of this article will be of some help to your study or work. If you have any questions, you can leave a message to communicate. Thank you for your support.