Trying to uninstall phpmyadmin "dpkg: error while cleaning up:"

When I’m trying to uninstall phpmyadmin by typing:

sudo apt-get remove phpmyadmin*

I get this:

Reading package lists... Done
Building dependency tree
Reading state information... Done
Note, selecting 'phpmyadmin' for glob 'phpmyadmin*'
The following packages were automatically installed and are no longer required:
  dbconfig-common dbconfig-mysql javascript-common libjs-jquery libjs-sphinxdoc libjs-underscore libmcrypt4
  linux-headers-4.4.0-57 linux-headers-4.4.0-57-generic linux-image-4.4.0-57-generic php-gd php-mcrypt
  php-phpseclib php-tcpdf php7.0-gd php7.0-mcrypt
Use 'sudo apt autoremove' to remove them.
The following packages will be REMOVED:
0 upgraded, 0 newly installed, 1 to remove and 54 not upgraded.
1 not fully installed or removed.
After this operation, 25.0 MB disk space will be freed.
Do you want to continue? [Y/n] y
(Reading database ... 124123 files and directories currently installed.)
Removing phpmyadmin (4: ...
/var/lib/dpkg/info/phpmyadmin.prerm: 44: /etc/dbconfig-common/phpmyadmin.conf: Syntax error: "(" unexpected
dpkg: error processing package phpmyadmin (--remove):
 subprocess installed pre-removal script returned error exit status 2
/var/lib/dpkg/info/phpmyadmin.config: 44: /etc/dbconfig-common/phpmyadmin.conf: Syntax error: "(" unexpected
dpkg: error while cleaning up:
 subprocess installed post-installation script returned error exit status 2
Errors were encountered while processing:
E: Sub-process /usr/bin/dpkg returned an error code (1)

Submit an answer

This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Want to learn more? Join the DigitalOcean Community!

Join our DigitalOcean community of over a million developers for free! Get help and share knowledge in Q&A, subscribe to topics of interest, and get courses and tools that will help you grow as a developer and scale your project or business.


Have you tried running without the glob (i.e. using the asterisk)?

sudo apt-get remove phpmyadmin

or simply purging the package:

sudo apt-get purge phpmyadmin

If neither of those work, you may want to run:

sudo apt-get -f install

… and then try running them again. The above will attempt to resolve any dependencies that may otherwise exist.

You can also run:

sudo apt autremove

… to remove the packages listed in the output since they are no longer in use/needed.

If nothing seems to be working, we can remove the dpkg files manually:

rm -r /var/lib/dpkg/info/phpmyadmin.*

… then run:

sudo apt-get clean \
&& sudo apt-get update \
&& sudo apt-get remove phpmyadmin \
&& sudo apt-get purge phpmyadmin

sudo mv /var/lib/dpkg/info/phpmyadmin.* /tmp/ sudo dpkg --remove --force-remove-reinstreq phpmyadmin sudo apt remove phpmyadmin sudo apt autoremove sudo apt autoclean

thanks me later!!!

So whenever anyone wants to remove phpmyadmin and apache just first of all stop all running services using below commands… stop apache2

sudo systemctl stop apache2.service

prevent apache2 to start at boot

sudo systemctl disable apache2.service