43

How do I fix the error below?

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

I use my NAS with a telnet connection.

I installed FFP 0.7

My php.ini is in: ffp/etc/php.ini and I uncommented everything I thought to be of use.

Below is a portion of my php.ini file;

;If you wish to have an extension loaded automatically, use the following
; syntax:
;
;   extension=modulename.extension
;
; For example, on Windows:
;
extension=msql.dll
;
; ... or under UNIX:
;
extension=msql.so
;
; ... or with a path:
;
extension=/ffp/lib/extensions/no-debug-non-zts-20100525/mysql.so
;


extension=php_mysql.dll
extension=php_mysqli.dll
extension=php_pdo_mssql.dll
extension=php_pdo_mysql.dll
extension=php_pdo_oci.dll
extension=php_pdo_odbc.dll
extension=php_pdo_pgsql.dll
extension=php_pdo_sqlite.dll
extension=php_pgsql.dll
extension=pdo.so
extension=pdo_sqlite.so
extension=sqlite.so
extension=pdo_mysql.so

The outstanding issue is that when I run in phpinfo(), I see the module MySQLi activated but not MySQL.

MySQL is working as expected just as PHP and Lighttpd web server.

I equally have phpmyadmin working.

It's on a Zyxel NSA310.

Also, when mysqld is started, it creates a shortcut from my root to: ffp/opt/mysql.. and every time I restart my NAS the shortcut is deleted.

Does anyone might know a trick for this?

nyedidikeke
  • 6,899
  • 7
  • 44
  • 59

27 Answers27

46

in the end i found a solution First, make sure MySQL server is running. Type the following command at a shell prompt:

/etc/init.d/mysql status

If MySQL is not running, enter:

/etc/init.d/mysql start

If MySQL is not installed, type the following command to install MySQL server:

apt-get install mysql-server

Make sure MySQL module for php5 is installed:

dpkg --list | grep php5-mysql

To install php5-mysql module enter:

apt-get install php5-mysql

Next, restart the Apache2 web server:

/etc/init.d/apache2 restart

Shoaib Iqbal
  • 1,208
  • 11
  • 21
marcboffin
  • 461
  • 1
  • 4
  • 3
  • 3
    I hate stackoverflow because it doesn't allow me upvote twice – Andrew Liu Oct 27 '15 at 00:24
  • i was missing this > # apt-get install php5-mysql Thanks bro i can sleep peacefully today. – Shridhar Apr 15 '16 at 14:27
  • 2
    sudo aptitude install php5-mysql <-- did it for me. Thank you! – Jay Jul 29 '16 at 07:30
  • 2
    if php 5.6 use `apt-get install php5.6-mysql` – Pranoy Sarkar Jan 10 '19 at 16:55
  • This answer is specific only to debian linux based servers that use apt. There are other OS's and distros (RHEL, Centos, etc) for example, for which this could easily be misleading. At this point nobody should be trying to run versions of PHP that are end of life. – gview Nov 25 '21 at 23:53
33

The php mysql api is deprecated. It's kaput --- going away -- not to be used, finito.

If you have a modern version of PHP (> 5.6) then Wordpress should automatically switch to make use of mysqli. That should be your first attempt.

If you can not update your php, rather than attempting to resurrect something that php no longer supports, just patch your wordpress: http://wordpress.org/plugins/mysqli/

If you are already running a modern version of PHP, then this is likely because you don't have the mysqli extension in your version of PHP. You can check this using php -i from your server OS, or make a page with <php phpinfo(); and navigate to that page with your browser. There will be section for all the extensions.

If you don't have the mysqli extension installed, follow the instructions from the official PHP documentation.

gview
  • 14,876
  • 3
  • 46
  • 51
  • the plugin hasn't been upgraded in last 2 years. This is no more suggested. It's better to update your php version to >=5.6 – Nitesh Apr 18 '17 at 16:42
  • Assuming modern version of wordpress and modern php, then yes, mysqli will be used and you should not have a problem. Obviously some people still have older versions and often have no control over the version of php being run on their servers. – gview Apr 19 '17 at 17:10
  • 3
    PHP 7 [doesn't come](http://php.net/manual/en/mysql.php) with `mysql` extension, so running older versions of WordPress is practically impossible. – x-yuri Feb 06 '18 at 18:07
  • 1
    Yes! I was having a hard time running locally an obsolete website with PHP56 and WordPress 3.7... placing `db.php` in my `wp-content` folder worked! Now I don't get anymore the error "Your PHP installation appears to be missing...". Thanks! – coccoinomane Jun 10 '19 at 18:45
11

This MySQL library worked for me:

sudo apt-get install php5-mysqlnd-ms
Downgoat
  • 13,771
  • 5
  • 46
  • 69
ashishyadaveee11
  • 1,021
  • 15
  • 17
11

After nearly seven years this keeps getting different answers.† Many are similar--but none identical--to what worked for me. Here's what worked for me (Ubuntu server).

Moving a site to a new server, forgot to install the PHP MySQL module/extension. I ran a quick

apt-get install php-mysql

and then

apachectl restart

Bada bing. No php5, php7; just plain php-mysql.

brasofilo
  • 25,496
  • 15
  • 91
  • 179
zedmelon
  • 373
  • 2
  • 10
  • Glad it helped! Not sure it qualifies as brilliant, but I've been on the receiving end of "straggler answers" in this vein--so I'm quite glad if this can help someone else quit pulling out their hair! :,) PS: thanks for the kind words and upvote – zedmelon Oct 24 '19 at 21:02
  • Incidentally--was the edited content superfluous or simply off-topic? It seemed at least tangentially related to me at least--would it maybe be appropriate for a meta discussion somewhere? Or am I merely regurgitating what's been lamented a thousand times? – zedmelon Oct 24 '19 at 21:03
  • Ah... I went back and saw you'd left a descriptive comment. I see. It was my hope that the dagger† signified enough of a diversion to segregate the statement from the main answer--but still denote it as "inspired by" the same. I didn't intend it so much as a rant as bringing forth an issue which might use improvement (not that I have any clue how to resolve it). – zedmelon Oct 24 '19 at 21:08
  • I just noticed the +100. Wow, TYVM! – zedmelon Oct 29 '19 at 21:09
  • Yeah, you saved my bacon, TYVM too :) I deleted my previous comments and will delete this one afterwards, so as not to derail from the technical aspect of your answer – brasofilo Oct 29 '19 at 22:38
  • Okay. I'm the sort that usually saves too much historical info--gets me into the prior mindset--and possibly a touch of nostalgia--I'll defer to your judgment here. :,) – zedmelon Oct 30 '19 at 17:49
10

Check the

extension_dir =

remove it if it is there. that should fix the problem.

pravchuk
  • 903
  • 10
  • 14
  • 1
    Oh... my.. god. I cannot thank you enough for this, or give you enough reputation (I don't think all of my reputation would justify the frustration you saved me). I just slammed my head against a wall for at least an hour with an inherited php.ini that had this set. This solved it, thank you, thank you, thank you! – hjc1710 Oct 11 '14 at 02:47
  • 2
    I changed the PHP version in cPanel and it brought down all of my wordpress sites. The default pages timed out with a 'Too many redirects' error and trying to browse to a specific file gave the 'Your PHP installation appears to be missing the MySQL extension which is required by WordPress.' error. As suggested removed the extension_dir line and it brought back the site! Thank you so much!!! – Merill Fernando Mar 03 '16 at 10:51
  • My extension_dir is set but I cannot remove it. It's commented out in the php.ini file so I don't know where it's getting it's path from. – Niall Lonergan Mar 08 '19 at 15:53
7

If people are using shared Linux hosting with cPanel (Godaddy, Reseller club, Hostgator or any Shared Hosting), try the following:

Under Software and Services tab -> Select PHP Version -> PHP Selectors | Extentions

Tick all MySQL related extensions, save it and you are done. Please check the attached image.

Image showing the extensions in cPanel

Burgi
  • 421
  • 8
  • 24
subhash Porje
  • 71
  • 1
  • 2
5

When you upgarde your php version, make sure, apache2 follows. You can create a phpinfo() file which could show that apache is still using the old php version.

In this case you should use the a2dismod php-old-version and a2enmon php-mod-version commands

Exemple :

in ubuntu, your grab the old version from /etc/apache2/mods-enabled, or from the version shown by the phpinfo file, and you grab the new one from /etc/apache2/mods-available

> sudo a2dismod php5.6
> sudo a2enmod php7.1
> sudo service apache2 restart
amine
  • 320
  • 3
  • 7
5

This Error is created by the WP core file /wp-includes/load.php and the function name is wp_check_php_mysql_versions().

The older versions of the WP does not support MySqli. But the latest WP versions support both MySql and MySqli extensions without bothering installed PHP versions.

Solved my problem 100%

In my case, I just updated the Wordpress core files manually and solved the issue :)

Reza Mamun
  • 5,991
  • 1
  • 43
  • 42
  • Besides the mentioned wp_check_php_mysql_versions() function, it should be enough to update the wp_db.php file in the same directory. – Linulin Oct 17 '17 at 08:27
  • @Reza,, Could you please tell what exactly you did. I am able to found the function in load.php... Then what i need to do to fix this problem, last link is not working for now, i mean no information.. if you could please share the steps what and where to update , it will be great – Gaurav Khurana May 10 '20 at 12:35
  • 1
    @Gauravkhurana I have just replaced Wordpress's default files and folders. You can just follow https://wordpress.org/support/article/updating-wordpress/#manual-update – Reza Mamun May 12 '20 at 04:54
4

I'm using Fedora 25

sudo dnf search php | grep mysql

php-mysqlnd.x86_64 : A module for PHP applications that use MySQL databases
php-pear-MDB2-Driver-mysqli.noarch : MySQL Improved MDB2 driver mysqli

sudo dnf install php-mysqlnd.x86_64
Burgi
  • 421
  • 8
  • 24
Ng Zhong Qin
  • 1,211
  • 2
  • 15
  • 28
4

It maybe the reason The php mysql api is deprecated. if your using below < PHP5.5 just update in your server to 5.6 and above.

Raj008
  • 3,539
  • 2
  • 28
  • 26
4

When I upgraded my website PHP from version 5.6 to 7.2, I encountered this problem “Your PHP installation appears to be missing the MySQL extension which is required by WordPress”. It turns out that mysql extension is no longer supported in PHP version 7.2. It is now using mysqli extention. I am using old version of WordPress which still using mysql extension that is why the problem existed. So what I did is upgraded the WordPress to the core. This solve the problem.

Here's the steps I followed when upgrading WordPress manually.

  1. First I created a full backup of my website. This is very important in case of mistake.
  2. I download the newest WordPress ZIP file from wordpress.org.
  3. I unzipped the file into a local directory of my computer.
  4. I went to my website root directory and deleted your ‘wp-includes’ and ‘wp-admin’ directories. I used sFTP connection using Filezilla software.
  5. I uploaded the new wp-includes and wp-admin directories from the new version of WordPress I unzipped to my website root directory and replaced the directories I just deleted.
  6. I did not delete the wp-content directory or any of the files in that directory. I just copied over the files from the wp-content directory in the new version of WordPress to my existing wp-content directory. All existing files with the same name have been overwritten.
  7. I copied all files from the root (‘/’) directory of the new version of WordPress that I unzipped into my website root directory (or the root directory of your WordPress installation). Existing files has been overwritten and new files has been copied across. wp-config.php file was not be affected because WordPress has never distributed with a wp-config.php file.
  8. I compare wp-config-sample.php which was distributed with WordPress but did not find anything to change so I just used the old one.
  9. I cleared my browser cache to ensure I can see all changes.
  10. I checked the site and there is no error now. The upgrade was completed.
halfer
  • 19,824
  • 17
  • 99
  • 186
3

If you have Wordfence plugin installed I found commenting out the suPHP_ConfigPath lines in the .htaccess file brought the website back to life:

# Wordfence WAF
#<IfModule mod_suphp.c>
#   suPHP_ConfigPath '/home/a1614947/public_html'
#</IfModule>

I've reported this to Wordfence too.

Dan Snik
  • 39
  • 1
3

Make sure you tick Mysqli and mysqlnd as shown in the screenshot enter image description here

csandreas1
  • 2,026
  • 1
  • 26
  • 48
3

In my case, using CPanel PHP selector and selecting the mysqli and mysqlnd worked. Ensure to save and recheck once

2

I had same issue as mentioned " Your PHP installation appears to be missing the MySQL extension which is required by WordPress" in resellerclub hosting.

I went through this thread and came to know that php version should be greater than > 5.6 so that wordpress will automatically gets converted to mysqli

Then logged into my cpanel searched for php in cpanel to check for the version, luckly was able to find that my version of php was 5.2 and changed that to 5.6 by making sure mysqli is tick marked in the option window and saved it is working fine now.

Mallesh.N
  • 21
  • 1
2

This issue was due to lack of database. If it is a fresh installation, you need to manually create one and assign user with privileges.

Please check in wp-config.php for any bad configurations and make sure that database and tables are not missing or corrupted.

  • This does not provide an answer to the question. Once you have sufficient [reputation](https://stackoverflow.com/help/whats-reputation) you will be able to [comment on any post](https://stackoverflow.com/help/privileges/comment); instead, [provide answers that don't require clarification from the asker](https://meta.stackexchange.com/questions/214173/why-do-i-need-50-reputation-to-comment-what-can-i-do-instead). - [From Review](/review/low-quality-posts/16494330) – Kurt Van den Branden Jun 22 '17 at 15:03
  • @KurtVandenBranden How is this not an answer? – Rob Jun 23 '17 at 00:19
2

Just install apt-get install php5-mysqlnd Restart Apache service apache2 restart

MOHAMED RAIYAN
  • 101
  • 1
  • 3
2

msqli and mysqlnd are checked

Make sure msqli and mysqlnd are checked in your php selector. Then go over change the name of your .htaccess file to .htaccess_old. See if your site can load now.

If it works, then go to your dashboard and save your permalinks, it will create a new .htaccess file.

This worked for me.

Mark Tickner
  • 1,023
  • 2
  • 15
  • 26
Anderson
  • 21
  • 1
0

For php 5.6 sudo apt-get install php5.6-mysqlnd-ms and restart your apache

/etc/init.d/apache2 restart
Pranoy Sarkar
  • 1,965
  • 14
  • 31
0

The source of this message was unrelated to the solution in my case.

My ip address of my server changed and i didn't change the <VirtualHost> directive in my httpd.conf of the apache server.

Once i changed it to the correct ip address the message disappeared and Wordpress is working again.

Tinus Tate
  • 2,237
  • 2
  • 12
  • 33
0

I have resolved the issue just adding following code in .htaccess file. I hope this will work for you guys also.

Step 1: Change the PHP version form the server.

Step 2: Add the following code in your .htaccess file according to your PHP version (Selected from the server).

To switch to PHP 4.4:

AddHandler application/x-httpd-php4 .php

To switch to PHP 5.0:

AddHandler application/x-httpd-php5 .php

To switch to PHP 5.1:

AddHandler application/x-httpd-php51 .php

To switch to PHP 5.2:

AddHandler application/x-httpd-php52 .php

To switch to PHP 5.3:

AddHandler application/x-httpd-php53 .php

To switch to PHP 5.4:

AddHandler application/x-httpd-php54 .php

To switch to PHP 5.5:

AddHandler application/x-httpd-php55 .php

To switch to PHP 5.6:

AddHandler application/x-httpd-php56 .php

To switch to PHP 7:

AddHandler application/x-httpd-php7 .php

To switch to PHP 7.1:

AddHandler application/x-httpd-php71 .php 
Hardik Kalathiya
  • 2,221
  • 1
  • 18
  • 28
0

On Oracle Linux 7.x running PHP version 7.3.x you need to run sudo yum install php-mysqlnd in order to install the missing MySQL extension for PHP.

Remember to restart PHP and or your server for the changes to take effect.

nyedidikeke
  • 6,899
  • 7
  • 44
  • 59
0

For me (ubuntu 16.04) the winner was:

sudo apt install php7.0-mysql
veggiebenz
  • 389
  • 5
  • 12
0

I just removed custom php ini, which I don't use at all. The problem gone, site is working fine.

0

As few people shared to tick mark the checkbox for mysqli and mysqlind

but Hostgator (webhosting site) now does not give that option to select extension via the cpanel as that option is removed select PHP and now it gives the option for php manager

You can just select the Php version you want and not the extension.

Solution :- Called the hostgator , first time they said get in touch with your developer, ( i asked my brother and he downloaded the files locally and verified it was working fine on local system) <-- this was not needed though

Again called the hostgator and their backend team installed the missing extension and it was solved.

Below is the code which gives this error when it does not find the extension and you can find this line in load.php via ftp.

if ( ! extension_loaded( 'mysql' ) && ! extension_loaded( 'mysqli' ) && ! extension_loaded( 'mysqlnd' ) && ! file_exists( WP_CONTENT_DIR . '/db.php' ) ) {
    require_once ABSPATH . WPINC . '/functions.php';
    wp_load_translations_early();
    $args = array(
        'exit' => false,
        'code' => 'mysql_not_found',
    );
    wp_die(
        __( 'Your PHP installation appears to be missing the MySQL extension which is required by WordPress.' ),
        __( 'Requirements Not Met' ),
        $args
    );
    exit( 1 );
}

}

Gaurav Khurana
  • 3,423
  • 2
  • 29
  • 38
0

I got the same issue.

I have checked my website's php version and it was old. I have corrected and reset it to the latest one.

The issue has been resolved by resetting php version.

0

One common scenario for such cases is when upgrading to PHP 7.4 or higher, there is conflict is because of nd_mysqli is enabled.

Fix: disable nd_mysqli extension and enable mysqli extension in [cPanel > Select PHP Version]

Enable the following mysqli extensions:

mysqlnd
nd_mysqli
nd_pdo_mysql

Disable following extensions:

mysqli
pdo_mysql
Deepak Rajpal
  • 811
  • 1
  • 8
  • 11