CentOS 7.2, PHP 5.4 - MySQL extension is missing

13,910

Solution 1

Alright... finally, so it turns out all I needed to do was restart PHP-FastCGI. Yay.

systemctl restart php-fastcgi.service

Solution 2

Modern PHP applications use the mysqli extension which supersedes the insecure (and now deprecated) mysql extension. This should be enabled by default when you install the php-mysql package but you can check it by running:

$ cat /etc/php.d/mysqli.ini

; Enable mysqli extension module
extension=mysqli.so

To be sure that this module is enabled, check that this module is listed in the PHP info page that you showed a sample of. Note that it’s listed further down the page in the modules section.

If you have the PHP command line interface installed (from the php-cli package) you can easily check by running php -i | grep -i mysqli. This should include the following line:

MysqlI Support => enabled
Share:
13,910

Related videos on Youtube

Sayem Khan
Author by

Sayem Khan

Updated on September 18, 2022

Comments

  • Sayem Khan
    Sayem Khan over 1 year

    I'm trying to install a Wordpress blog on my Linux server (CentOS 7.2), using PHP 5.4 and MariaDB, but I keep running into this error:

    Your PHP installation appears to be missing the MySQL extension which is required by WordPress.
    

    Have been searching around for posts related to this:

    However, I already have php-mysql installed:

    enter image description here

    And I have the MySQL extension configured for php.ini:

    enter image description here

    But for some reason, the MySQL extension still isn't loading in phpinfo():

    enter image description here

    That's probably causing this error from Wordpress, any idea what might be happening? Why isn't the MySQL extension getting loaded in PHP? Maybe because I'm using MariaDB?

    And here's the output of:

    ls -l /etc/php.d , rpm -ql php-mysql and ls -l /usr/lib64/php/modules/
    

    enter image description here

    enter image description here

    enter image description here

    And the mysqli extension is installed and enabled:

    enter image description here

    enter image description here

    • Damiano Verzulli
      Damiano Verzulli over 8 years
      Please, can you provide the output of ls -l /etc/php.d , rpm -ql php-mysql and ls -l /usr/lib64/php/modules/ ? As you're using CGI/FastCGI server-API, I want to be sure there are no file-permission problems. Also: are you running under SELINUX?
    • Sayem Khan
      Sayem Khan over 8 years
      I'm not running SELINUX, it's disabled. Just updated the post with those outputs, I have mysql and mysqli in all of those directories.
    • kasperd
      kasperd over 8 years
      Please don't post screenshots of a terminal. Instead copy the text from the terminal to your question and use the code formatting feature.
    • IndieTech Solutions
      IndieTech Solutions over 6 years
      ` yum install php71w-mysqlnd`
  • Sayem Khan
    Sayem Khan over 8 years
    Just updated the post with some more output, I do have the mysqli extension installed and enabled. However, I'm not seeing it show up in the PHP info page... any idea why it's not getting loaded?
  • Anthony Geoghegan
    Anthony Geoghegan over 8 years
    @SayemKhan That info looks fine. However, I've never ran PHP in CGI/FastCGI mode so I'm out of ideas. If I have time tomorrow evening (when I have access to a CentOS7 box), I'll try to replicate your set-up.
  • Sayem Khan
    Sayem Khan over 8 years
    Yup it turns out I forgot to restart PHP-FastCGI. Thanks for mentioning it and for your help.
  • godidier
    godidier over 5 years
    Thanks ! Had the exact same problem worked for me. Tho I used systemctl restart php-fpm. I am on Fedora 25