18

I am having trouble enabling mysql in my php-config.

apt-get install php-mysql and apt-get install php7.0-mysql don't make a difference.

Also, the shared object is missing from the php extension directory.

Is there any way I could get the mysql.so?

2
  • if your using php7, the php7.0-mysql version should be used only. Remove the other and see if it improves. Dec 7, 2016 at 20:38
  • In ubuntu 16.10 : /usr/lib/php/20151012/mysqli.so is provided by php7.0-mysql package. Check /etc/php/7.0/apache2/conf.d/20-mysqli.ini, you should have : extension=mysqli.so
    – f35
    Dec 7, 2016 at 21:50

6 Answers 6

24

On Ubuntu, I fixed this error by running

sudo apt-get install php-mysql

And then restarting my server (caddy, apache, nginx).

source

3
  • Couldn't get this to work on PHP7.1, Ubuntu 16.04 (mysql was still missing)
    – The Onin
    Aug 15, 2017 at 0:11
  • 1
    The error I got, which this information helped me fix: "PHP is missing the MYSQL EXTENSION that WordPress needs".
    – givonz
    Nov 7, 2017 at 17:20
  • On Ubuntu 16.04 I had to force it to use php7.0-mysql even though I'm actually using php 7.3 (Wordress version 5.2)
    – Dagmar
    May 19, 2019 at 10:28
5

I'd assume you're talking about the (very) old style MySQL functions in PHP like mysql_connect() or mysql_query(). Those functions have been deprecated for years and years, and have finally been removed in PHP 7. Use the mysqli extension or one of vendor-independent abstraction layers like PDO instead.

2

I had this exact question but related to a very specific version of Ubuntu on a Docker image. The trick was to update and install in the same RUN command.

RUN apt-get update && apt-get install php7.0-mysql
1
  • Thank you so very much. php7.0-mysql was the offending missing package(s) =)
    – sova
    Dec 13, 2020 at 3:02
0

mysql extension was removed in PHP 7.

You should use mysqli or pdo_mysql instead.

If you still need to use mysql functions (eg. for legacy code support), you may compile the mysql extension manually.

Here's the procedure: https://ckon.wordpress.com/2015/08/06/put-mysql-functions-back-into-php-7/

0

mysqli.so is indeed flagged missing and seemingly NOT installed in 18.04. It appears to me the packages are broken because there is a php-mysqli and it is not installed while php-mysql is.

I was not able to install the php-mysqli package otherwise and it throws no errors in apt when I try, it just doesn't install anything.

However, I found mysqli.so in /var/lib/php/modules/7.2/cgi/enabled_by_admin/.

Add extension=/path/here/to/mysqli.so under your extension=mysqli in php.ini and you should stop throwing the mysqli.so missing error.

IMHO these packages are borked and it isn't entirely clear what provides mysqli.so, and won't work out of the box unless you enable the extension and set your path for the extension once you find it (you can use dpkg-query -L to see if mysqli.so is part of the package contents, and where it gets installed)

-3

If I understand correctly, installing LAMP stack should fix your issue. Try this guide

https://www.unixmen.com/how-to-install-lamp-stack-on-ubuntu-16-04/

1
  • 1
    Op want's help for mysql not the whole stack Jun 26, 2017 at 9:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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