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

42 Comments
Conor (5 comments.) on January 3, 2007 at 6:54 pm.
I thought for linux you’d have to recompile PHP with the mysql or mysqli option?
Donncha (1707 comments.) on January 3, 2007 at 7:06 pm.
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?
Hetch on November 2, 2011 at 9:24 am.
hey man is it ok to install php separately when you already have wamp server installed on your pc
adam (1 comments.) on January 4, 2007 at 1:11 am.
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.
cogmios (1 comments.) on March 1, 2009 at 8:14 pm.
or “ipkg install php-mysql”
Conor (5 comments.) on January 4, 2007 at 2:40 am.
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.
Donncha (1707 comments.) on January 4, 2007 at 3:51 pm.
Thanks Adam for the RPM instructions. I had quite forgotten about Yum!
Conor – ye’re crazy!
andrea on February 21, 2007 at 11:28 am.
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!
Donncha (1707 comments.) on February 21, 2007 at 11:39 am.
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.
andrea on February 21, 2007 at 12:02 pm.
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?
Donncha (1707 comments.) on February 21, 2007 at 12:04 pm.
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
andrea on February 21, 2007 at 12:24 pm.
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!
David Precious (18 comments.) on March 23, 2007 at 7:41 pm.
“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.
Orca (1 comments.) on April 6, 2007 at 6:22 pm.
I need the file mysql.so! Can someone can send me the file please at orcinus.orka@gmail.com. Thank you
Kaitlin Duck Sherwood (1 comments.) on April 8, 2007 at 3:24 am.
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.
Serg on April 18, 2007 at 2:05 am.
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.
Kattie Thebest on April 23, 2007 at 6:19 am.
apt-get install php5-mysql works a treat also
Lermont (1 comments.) on May 28, 2007 at 8:42 am.
Serg, is path to libmySQL.dll in the “PATH” environment variable?
skbz (1 comments.) on June 1, 2007 at 2:30 pm.
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
Andrew on September 20, 2007 at 11:39 pm.
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?
AK on September 21, 2007 at 4:15 pm.
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!
hassan on October 31, 2007 at 6:42 am.
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.
TopWebHosting on March 6, 2008 at 3:49 pm.
Oh. Thank you. I has been trying to fix this problem for hours. Luckily I found your suggestion and solution.
Thanks.
golden on June 16, 2008 at 6:37 am.
Thank you soooo much!!! I was just about to pull my hair out lol
Thanks
Shalini on September 3, 2008 at 2:08 am.
Thanks a ton! this conversation has fixed my problem!
Tran Anh on November 7, 2008 at 5:12 am.
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 .
Mark (1 comments.) on December 28, 2008 at 10:07 am.
It finally worked when I copied ‘libmysql.dll’ into my windows/system32 folder.
Crazy!
Anonymous on June 2, 2009 at 4:02 pm.
Yes, thanks, it’s working when i copied libmysql.dll into my windows/system32 folder
Esha on January 21, 2009 at 7:49 pm.
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
Daniel on March 4, 2009 at 11:25 pm.
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
Pingback: Overpass Experiences » Plesk Upgrade messed up Mysql and PHP
Atreidex on May 22, 2009 at 3:31 pm.
good job mate
Hoapino (2 comments.) on July 10, 2009 at 9:07 am.
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.
Dan on August 7, 2009 at 1:21 pm.
You need to install the php package on Cento OS. Then it will work…
Hoapino (2 comments.) on August 10, 2009 at 9:18 am.
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.
tendy on September 12, 2009 at 3:59 am.
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
Jacob (1 comments.) on October 24, 2009 at 12:09 pm.
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.
Crystal McClendon (1 comments.) on February 28, 2010 at 3:02 am.
THANK YOU!
THANK YOU!
THANK YOU!!!!!!!!!!!!
YEY IT WORKED!!!
Daniel on September 29, 2010 at 11:05 am.
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.
memare on December 22, 2010 at 8:13 pm.
thanks very much give me kod
yum install php-mysql
Greg on January 31, 2011 at 5:43 am.
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.
Huzoor Bux (1 comments.) on April 14, 2012 at 11:42 am.
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.