0

Getting error when installing php5-mysql. Looks like a dpkg error. Perhaps a broken package.

Have tried to fix the broken package. Have reinstalled the lamp server and everything seems fine except being able to install the php5-mysql extension, I get:

Errors were encountered while processing: php5-mysql  

The sub-process for dpkg is returning an error code.

Any ideas appreciated.

Marco Ceppi
  • 48,101
Daryl Wood
  • 11
  • 1
  • 1

2 Answers2

1

This technique is based on owl's answer, but:

  • It avoids deleting the .prerm file. This file is needed to ensure the package is uninstalled cleanly, and removing it could potentially leave traces of the package remaining, leave the system configured in a way that expects the package to be installed, or leave services provided by the package running, even once the files are removed.

    That makes this technique safer, though potentially it might not work if there is also a problem running the .prerm script. (This may have been why owl said to delete it.) Fortunately, usually the .prerm script does not fail.

  • This technique potentially removes more configuration files, so depending on the cause of the problem, this might be more effective.

    It also makes sure we are fetching the correct version of the package to install.

Run:

sudo dpkg -P php5-mysql
sudo apt-get --purge autoremove
sudo apt-get update
sudo apt-get install php5-mysql

If there are no errors, then everything is cleaned up from the previous installation and php5-mysql is installed. In that case, the package should work properly now.

Eliah Kagan
  • 117,780
-1

Why don't you try this command:

sudo rm /var/lib/dpkg/info/php5-mysqlnd.prerm

Or

sudo apt-get autoremove php5-mysql 

This allowed me to install php5-mysql again.

So install php5-mysql again:

sudo apt-get install php5-mysql
Eliah Kagan
  • 117,780
owl
  • 4,951