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!
44 thoughts on “Cannot load mysql extension. Please check your PHP configuration.”
I thought for linux you’d have to recompile PHP with the mysql or mysqli option?
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-mysqlor the same with rpm.
Gentoo has it’s emerge tool, while Slakware .. ?
Does anyone compile stuff anymore except for exotice plugins and code patches?
hey man is it ok to install php separately when you already have wamp server installed on your pc
yum install 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.
or “ipkg install php-mysql”
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.
Thanks Adam for the RPM instructions. I had quite forgotten about Yum!
Conor – ye’re crazy! 🙂
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!
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.
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?
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 🙂
ok, Donncha, I checked my php.ini and now I restart, and I’ll keep my fingers crossed, next days! Thank you for your help! 🙂
“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.
I need the file mysql.so! Can someone can send me the file please at firstname.lastname@example.org. Thank you
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.
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?
apt-get install php5-mysql works a treat also
Serg, is path to libmySQL.dll in the “PATH” environment variable?
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.
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?
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!
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.
Oh. Thank you. I has been trying to fix this problem for hours. Luckily I found your suggestion and solution.
Thank you soooo much!!! I was just about to pull my hair out lol
Thanks a ton! this conversation has fixed my problem!
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 .
It finally worked when I copied ‘libmysql.dll’ into my windows/system32 folder.
Yes, thanks, it’s working when i copied libmysql.dll into my windows/system32 folder
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.
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).
good job mate
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.
You need to install the php package on Cento OS. Then it will work…
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.
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
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.
YEY IT WORKED!!!
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.
thanks very much give me kod
yum install php-mysql
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.
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.
Thnx! This was all I had to do. 🙂
I still can not make it work on ubuntu 15.10? Any recommendation? I still can not find mysqli or mysql loaded in phpinfo() function.