I am trying to install mysql on my pi. I've installed mysql server successfully, but get the following error when I try to run

$ sudo apt-get install php5-mysql

Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:

The following packages have unmet dependencies:
 php5-mysql : Depends: libmysqlclient18 but it is not installable
E: Unable to correct problems, you have held broken packages.

Any ideas what I can do to fix this?


4 Answers 4


I solved this problem replace php5-mysql by the php version installed. The php version is show with:

$sudo php --version

PHP 7.0.19-1 (cli) (built: May 11 2017 14:04:47) ( NTS )
Copyright (c) 1997-2017 The PHP Group
Zend Engine v3.0.0, Copyright (c) 1998-2017 Zend Technologies
 with Zend OPcache v7.0.19-1, Copyright (c) 1999-2017, by Zend Technologies


$ sudo apt-get install php7.0-mysql

$sudo systemctl restart apache2

I managed to install with:

sudo apt-get install php-mysql

It appears that PHP 7 packages are then installed instead of the 5 version.

  • Have you switched to Raspbian Stretch, by any chance? I believe PHP 7 is in that repo, but not Jessie.
    – Aurora0001
    Aug 26, 2017 at 10:09

Using the command

apt-cache search mysql | grep mysql

you'll find exactly which the versions of php and php-mysql might be used. In my case (Raspbian 8.0 Jessie) I have php5 and php5-mysql.


Maybe try apt-get update && apt-get dist-upgrade and then try installing php5-mysql or php-mysql or you can try answer from this similar question

Failed MySQL install (Raspbian)

  • 1
    I fear without first clearing the held broken packages this might not better but worse the situation.
    – LotPings
    Aug 21, 2017 at 10:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.