Cannot load mysql extension. Please check your PHP configuration. phpMyAdmin

phpMyAdmin - Wikipedia

phpMyAdmin is a popular tool used by many web hosts, control panels and web developers as an easy way to manage there mySQL databases. For the PHP enthusiasts as well, as the name might suggest, the panel is written in PHP. Now, some might think that the panel looks a bit dated (hello 90’s) but it’s a powerful tool that gets the job done without fuss. And, as it’s not customer facing, who cares about fancy graphics when you have power and speed?

We covered yesterday the dreaded ‘Fatal error: Call to undefined function mysqli_connect()‘ error that can occur when using the mysqli plugin in PHP. The error we are looking at today is a distinct error in phpMyAdmin, but shares many commonalities with this error.

The cause

Similary to the error we looked at yesterday, this error is being thrown by PHP as it doesn’t have the first clue what mysqli. In other words, it doesn’t exist. And, in the same way that our own code throws fatal errors when we try to speak in a language it doesn’t understand, so does phpMyAdmin. Why? Because it’s just another PHP application! Of course phpMyAdmin is likely much more complex than the application we’re trying to run but the fundamentals are the same. Whether it’s phpMyAdmin or your own PHP application, if we expect it to ‘talk’ to mySQL, we need to provide it with the means to do this – via the mySQLi plugin.

BUT I hear you call out – everybody is using it! They are – and the reason they can use it but your current setup isn’t allowing it is because you don’t have the appropriate MySQLi adapters installed along correctly on your server.

Why does the error look different in phpMyAdmin compared to my own PHP application?

If you run your own PHP code now, using mysqli_connect(), it is almost certain you will come across the ‘Fatal error: Call to undefined function mysqli_connect()‘ error. If you’ve not got an application that’s already using it to test, create a quick test.php file and throw the following code into it:

$mysqli = new mysqli("localhost","my_user","my_password","my_db");

Expected error:

Fatal error: Call to undefined function mysqli_connect()

How do I fix this?

There are two ways you can do this:

  1. EasyApache (easier)
  2. Terminal/Command line (harder)

EasyApache fix

  1. Login to WHM as the main (usually ‘root’) user.
  2. Select ‘EasyApache’ from the menu on the right hand side.
  3. Select your ‘Previously Saved Config’ – this will ensure you keep all your existing profile settings from the last time you complied/recompiled Apache.
  4. Click the ‘Start’ button to start customising the profile.
  5. You can keep your Apache and PHP versions the same by clicking the ‘Next’ button.
  6. For the additional options, you’ll need to select the MySQL Improved extension from the ‘Exhaustive Options List’.
  7. Save and build. Once finished Apache should automatically restart and if you re-run your code above it should now work as MySQLi support has been added.

EasyApache should work it’s magic on your php.ini file to get you up and running.

Command Line/Terminal fix

On a Linux based server, in the terminal you can enter the following command to retrieve and install the php-mysql package to enable support for the mysqli commands:

sudo apt-get install php-mysql

You may need to reboot your server after installation is completed.

Configuration of mySQL for PHP

You may need to edit your PHP.ini file in the following two cases:

  • You’ve not previously enabled mySQL support in PHP
  • It hasn’t been automagically enabled when you installed the php-mysql extension (more likely using the command line fix than EasyApache).

Should you want to check the configuration, and make the change if required, the steps are quite simple.

Open the PHP.ini file and search for:

This line may be commented out like so:


If it is, simply remove the semicolon (;) from the beginning of the line to uncomment it and enable it. If you’ve previously deleted this line, or cannot find it, you can simply add the line above safely to your php.ini file (without the semicolon at the beginning) for the same effect.

Finally, restart your Apache server (either through your control panel or, if running locally, quit the server and restart the application) and hey presto, phpMyAdmin (and your code!) should run like a dream now!

Want to confirm it’s fixed?

Simply run phpMyAdmin (or your test code) and if you’ve successfully implemented the steps you’ll see neither of the errors any more. For further verification, you can create a test.php file and simply place this inside:


Once executed it’ll print out a lot of information. You are looking for the line that says: ‘Mysqli Support – enabled’.

Hit us up in the comments below if either of the fixes worked for you or if you’re still encountering any issues!

You may also like...

0 0 votes
Article Rating
Notify of
Inline Feedbacks
View all comments
Would love your thoughts, please comment.x