Solution for Postgresql uninstall error under Ubuntu

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):
 Child process has pre installed-The removal script returned error number 2
dpkg: postgresql-client-9.1: dependency problems, but removing anyway as you requested:
 postgresql-9.1 Depends on 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):
 Child process has pre installed-The removal script returned error number 2/var/lib/dpkg/info/postgresql-client-9.1.postinst:7:.: Can't open /usr/share/postgresql-common/maintscripts-functions
dpkg: error while cleaning:
 Child process has installed post-The installation script returned error number 2
An error occurred during processing:
 postgresql-9.1
 postgresql-client-9.1
E: Sub-process /usr/bin/dpkg returned an error code(1)

Use the following command:

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

Afterwards

sudo apt-get autoremove postgresql*

Finally, you can see:

dpkg: warning: files list file forpackage'postgresql-9.1' missing; assuming package has no files currently installed
dpkg: warning: files list file forpackage'postgresql-client-9.1' missing; assuming package has no files currently installed(Reading database...There are currently 146453 files and directories installed in the system.)
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 that the first command deletes dpkg's metadata information about postgresql, and then when using the autoremove command, dpkg thinks that postgresql is not installed, and then prompts that the uninstallation was successful.

Recommended Posts

Solution for Postgresql uninstall error under Ubuntu
There is no solution for Chinese input method under ubuntu
Use QQ under Ubuntu 13.10, suitable for 14.10
Install YouCompleteMe plugin for vim under Ubuntu
Install PyTesser under ubuntu 14.04 for OCR recognition
Solution for Ubuntu unable to connect to the network
The solution to the failure to install .deb under Ubuntu 16.04
Steps to add toolkit for Matlab_Linux under ubuntu
Solution to pycharm unable to import classes under Ubuntu
ubuntu installation error
The same solution for cloning ubuntu18 virtual machine ip
Manual for Ubuntu Installation
Install apache+PHP under Ubuntu
Install postgresql-10 on Ubuntu 18.04
Install python3.6 under Ubuntu 16.04
Ubuntu18.04 install opencv 3.2.0 solution
Install mysql under Ubuntu 16.04
Install Thrift under ubuntu 14.10
Install OpenJDK10 under Ubuntu
Install Caffe under Ubuntu 14.04
Python MySQLd under Ubuntu
Start working under ubuntu
Install PostgreSQL12 under CentOS7
[python] python2 and python3 under ubuntu
Use iptables under ubuntu
2018-09-11 Install arduino under Ubuntu
LNMP installation under Ubuntu
Network configuration under Ubuntu
Install ROS under ROS Ubuntu 18.04[2]
Install MySQL under Ubuntu
Install Yarm-PM2 under Ubuntu
ubuntu dpkg software uninstall
How to create LVM for XFS file system under Ubuntu
Detailed steps for installing Django under Python 3.6 in Ubuntu 16.04 environment
Method steps for installing and configuring SSH service under Ubuntu 18.04