How to solve an error in uninstalling Postgresql in Ubuntu: ubuntupostgresql
Preface
An error occurred while uninstalling the PostgreSQL database recently. Instead, you can troubleshoot and solve the problem step by step. Here we will share the solution process and learn from friends who have encountered this problem, I won't talk much about it below. Let's take a look at the detailed introduction.
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-functionsdpkg: error processing package postgresql-9.1 (-- remove ): the sub-process has installed the pre-removal script and returns the error code 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-functionsdpkg: error processing package postgresql-client-9.1 (-- remove ): the sub-process has installed the pre-removal script and Returns Error Code 2/var/lib/dpkg/info/postgresql-client-9.1.postinst: 7 :.: Can't open/usr/share/postgresql-common/maintscripts-functionsdpkg: An error occurred while cleaning: the Sub-process installed post-installation script returns error number 2 errors occurred during processing: postgresql-9.1 postgresql-client-9.1E: Sub-process/usr/bin/dpkg returned an error code (1)
Solution Process
Run the following command:
sudo rm -r /var/lib/dpkg/info/postgresq*
Then
sudo apt-get autoremove postgresql*
Finally, you can see:
Dpkg: Warning: files list file for package 'postgresql-100' missing; assuming package has no files currently installeddpkg: Warning: files list file for package 'postgresql-client-100' missing; assuming package has no files currently installed (Reading database... the system currently has 146453 files and directories installed .) 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 deletes the metadata information of dpkg about postgresql. When you use the autoremove command, dpkg assumes that postgresql is not installed and then prompts that the uninstall is successful.
Summary
The above is all the content of this article. I hope the content of this article will help you in your study or work. If you have any questions, please leave a message, thank you for your support.