Cannot load mysql extension. Please check your PHP configuration.

A friend recently had a problem configuring a new server. He installed PHP, Apache, MySQL and phpMyAdmin but when he launched it he got the following error:

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

If you’ve installed all of the above more than once you’ll know what is more than likely wrong. The MySQL PHP module isn’t loaded. First of all, you must find your php.ini. It could be anywhere but if you create a small php file with the phpinfo(); command it will tell you where it is. Common places include /etc/apache/, /etc/php4/apache2/php.ini, /etc/php5/apache2/php.ini or even /usr/local/lib/php.ini

Edit your server’s php.ini and look for the following line. Remove the ‘;’ from the start of the line and restart Apache. Things should work fine now!

;extension=mysql.so

should become

extension=mysql.so


You might also like

If you like this post then please subscribe to my full RSS feed. You can also click here to subscribe by email. There are also my fabulous photos to explore too!

"Cannot load mysql extension. Please check your PHP configuration.", 2 out of 5 based on 11 ratings.

Published by

Donncha

Donncha Ó Caoimh is a software developer at Automattic and WordPress plugin developer. He posts photos at In Photos and can also be found on Google+ and Twitter.

43 thoughts on “Cannot load mysql extension. Please check your PHP configuration.”


  1. Well, there is that, but if you’re using a modern version of Linux then all you’ll have to do is apt-get install php4-mysql or the same with rpm.
    Gentoo has it’s emerge tool, while Slakware .. ?

    Does anyone compile stuff anymore except for exotice plugins and code patches?


  2. yum install php-mysql
    up2date php-mysql
    rpm -Uvh php-mysql*

    (For the latter you’ll need to get the actual RPM first.)

    The PHP packagers have conveniently followed Linux and Apache down the *.d configuration, so the RPMs will dump a configuration file into the /etc/php.d directory, enabling it automatically.


  3. Does anyone compile stuff anymore except for exotice plugins and code patches?

    I do! Most of the stuff on my box I tend to compile straight from source. Why I don’t know its just a habbit thats seem to stuck with me. Sometimes I’ve found the binary package isn’t always up to date.


  4. I have a similar problem, but I cant’fix it…launching phpMyAdmin, today I get the following error: “phpMyAdmin – Error
    Cannot load mysql extension. Please check your PHP configuration.”

    The story so far: I decided to update MySQL on the server. After reading a handful of tutorials, I got it updated, running, and working properly.

    Today, I get the above-mentioned phpMyAdmin error, and when check apache error.log I get:
    “Fatal error: Call to undefined function: mysql_connect() in /var/www/html/index.php on line 5″

    I touched nothing: what would make it get that error all of a sudden? I can understand if I had that problem right after I updated, but why would it be delayed by a day or two?
    I’m not sure exactly what happened, but it sounds like it might have been some automated process…
    (Moreover, my up2date does not work: I get an error like “HTTP Error 404: Not Found”…)

    Could anyone help me to get it out?

    thank you very much!


  5. Andrea – mysql isn’t loaded. Check your php.ini, it might have been overwritten. There’s a line to load mysql. Look for “mysql.so”. If there’s a ‘;’ at the start of the line remove it and restart Apache.

    I’m not sure what the Red Hat package is, but check that there’s a php-mysql rpm installed too.


  6. yes, i think you’re right…but what i don’t understand is why this problem arose after three days since I uploaded mysql?

    So, if I change php.ini, in a few days may I experience again this problem?


  7. I don’t know why, except that Apache might not have been restarted when PHP was updated. It was restarted 3 days later, maybe when log files were rotated.

    You shouldn’t get this problem again, hopefully :)


  8. “Does anyone compile stuff anymore except for exotice plugins and code patches?”

    Yes, I often do. Compiling software with just the options you want, and all the compiler optimisations for your specific hardware can be worthwhile.

    I tend to only do this for servers though… I used to do it for all machines, but these days I’m getting lazy and use Arch Linux (www.archlinux.org) for workstations, as it has a great package management tool (cunningly named “pacman” :) ). Slackware is still my distro of choice for servers.


  9. I also was missing mysql.so; I found it by getting the package php4-mysql. I used Synaptic, but apt-get should use the same name.


  10. Cannot load mysql extension in Windows.
    PHP 5.0, MySQL 5.1
    I’m getting a message PHP Startup: Cannot load dynamic library c:\PHP\php_mysql.dll . The specific procedure could not be found.
    I have the file there with all right permission as well as libmySQL.dll. I’ve dropped the files as well to system directory. Nothing helps.

    Any other ideas?
    Thanks.


  11. Ola,

    thanks for this thread. I’ve just spent the best part of four days on this problem and seen several threads discussing the same thing.

    I checked and double checked, installed, removed, cleaned, resinatlled, followed the procedure again and still got the same error.

    Im running a WIMP environment and it turns out that the fix is to remove libmysql.dll and replace it for the one in the zip file – don’t use the one in the .msi ‘easy’ install version. The two files are different sizes and have differernt datestamps on.

    As soon as I restarted mysql service after performing this operation, everything just started working. \o/

    I hope that sharing this will save some people a good deal of time if they have the same issues.

    peace


  12. Hey guys,
    i am installed mediwiki on my site and when running the install script get stuck at this point.

    Could not find a suitable database driver!

    * For MySQL, compile PHP using –with-mysql, or install the mysql.so module

    I followed previous posts and removed the ‘;’ at the beginning of the line from php.ini in /etc/php5/apache/php.ini and did a graceful restart.. but made no difference..

    any other clues?


  13. Thanks. After installing PHP, I could find no sign of MySQL anywhere. I was in the midst of recompiling when I found your page. You saved me quite a headache!


  14. hi guys,
    i have installed both dll files in c:/php directories and set environment variable also but in drupal index page i am getting error

    “We were unable to use the MySQL database because the MySQL extension for PHP is not installed. Check your PHP.ini to see how you can enable it.”
    any one can help me about this plz.


  15. Oh. Thank you. I has been trying to fix this problem for hours. Luckily I found your suggestion and solution.

    Thanks.


  16. hello everyone

    i got stuck there with Php5 and Mysql5 installation on AIX 5.3 system .they appear the exactly happening follow this instruction post but its doesnt work for me until now.

    i check out my php.ini configuration then found out the extension_dir = “/opt/freeware/lib/php/modules” but i go to that default folder and find out there’s empty folder .

    extension=mysql.so doest work in this situation anyway .Thats strange when i check other system which had php4.4.8 and mysql 5.0.27 installed its work fine then it doesnt enabled the extension=mysql.so on its php.ini configuration .


  17. Hi,

    This post and the comments have been really useful. I too am trying to install phpMyAdmin and get the same “Cannot load mysql extension. Please check your PHP configuration” error. This is on unix. I copied over the mysql.so file and changed the php.ini file, but I still get the same error. PHP wasn’t configured correctly on the system and there was no php.ini file, so I copied one over. Also, I just copied the mysql.so file over. Should I reconfigure php with the mysql option, or are there any other suggestions? I would really appreciate it. Thanks.

    Esha


  18. Hi guys,
    I’m going mental…
    I’m trying to install Simple Forum Machine on a LAMP server and I get the error

    “The installer was unable to detect mySQL support in PHP.PLease ask your host to veirfy that PHP was compiled with mySQL, or that the extension is being loaded”

    I modified the teh php.ini file to include extension=mysql.so and I copied the extension into the /usr/lib/php/modules folder (I’m running CentOS 5.1).

    any suggestion?

    Thanks

    DAniel


  19. Hi guys!
    On my testing server running windows XP, my WAMP enviroment is running fine. The problem arise when I try to set up LAMP enviroment on my Sentos pc.
    I modified the php.ini file to include extension=mysql.so, entension dir is correct and I copied the extension into the /usr/lib/php/modules folder (I’m running CentOS 5.1).
    Most of linux server run properly under this settings but sentos. Plaese assist.


  20. I re-installed php package and nothing changes.
    Maybe I should clarify that on Fedora all is well but Centos 5.1 is a stubborn.
    Actually I never thought I will face a problem like this cause I set up windows XP and Fedora myself, But Centos proved me wrong, please assist.


  21. Thanks DONCHHA
    for the tip “Well, there is that, but if you’re using a modern version of Linux then all you’ll have to do is apt-get install php4-mysql or the same with rpm.
    Gentoo has it’s emerge tool, while Slakware .. ?
    Does anyone compile stuff anymore except for exotice plugins and code patches?”
    I have been using mandriva and I installed the package php-mysql hence error is gone


  22. Thanks Adam, I use to get the error that MySQL Adapter ‘mysql’ in not available, but with YUM command for Php-mysql, everything boooooom, thanks again.


  23. Hola,

    Yo he instalado el utlimo php para integrarlo con iis en windows server 2003.
    Me da error: ” Parece que tu instalación de PHP no cuenta con la extensión de MySQL, necesaria para hacer funcionar WordPress.”

    Y en el php instale todas las extensiones y el php.ini tengo las extensiones descomentadas. EL directorio de extensiones es C:\php\ext(también inlcuido en el php.ini)

    Ya no sé a qué puede ser debido.Ayuda por favor.


  24. Hello,

    I hope you guys can help me;

    I am running fedora 14 distro, and currently attempting to configure LAMP..

    while trying to load htttp://localhost/phpMyAdmin, I get that ffffin error.

    I found Donnchas solution –tried it– and still no luck.

    Can anyone help!

    Thanks in advance.


  25. Hello Friends,

    I am getting same error on my centos server.

    Its working fine when i update my php to 5.3.10 it start giving me this error friends please help me.

Leave a Reply