Thursday, 26 February 2009

"Cannot load mysql extension. Please check your PHP configuration" Error with XAMPP

so, if your like me, you've downloaded XAMPP... managed to get apache to start, but having trouble with MYSQL integration, then read on....
If you are simply trying to integrat php and mysql, then you may still find this useful.

You may receive this warning when attempting to access the local MYSQL instance packaged with XAMPP. Usually, this is noticed by clicking on the phpmyadmin on the XAMPP control panel.

1. For me: the problem was because i already had PHP installed on my PC. Therefore, the old installation was being used and it was conflicting!!

2. For others: The problem was due to the "php_mysql.dll" extension being excluded from the php.ini file.

- open php.ini located within the main php dir. For me, this is .\xampp\php\.
- Find "extension=php_mysql.dll" and ensure the semicolon is removed from the start of the string. This will then include the mysql extension.
- Now find the "extension_dir" string, and ensure it points to the 'ext' dir within the php dir. For me, this value is: extension_dir = "\xampp\php\ext\"

3. Lastly: Others find the problem is with a currupted mysql configuration file. This is located within the 'mysql\bin' dir. For me, this is ".\xampp\mysql\bin".
This is a cnf file, and for Windows users, this is the same extension as a SpeedDial file, so it will just be called "my". The best way to edit this, is to use the 'winmysqladmin.exe' tool located in the same directory, or drag the file onto Notepad.exe. Ensure the port is setup to a free port on your system... Mine is the default: 'port= 3306'.

If this is still not working, open "winmysqladmin.exe". (this is now an unsupported application, use phpmyadmin for anything else! You may receive DLL errors when using, but just ignore them.). Execute the 'my.ini setup' tab and a new configuration file can be saved out from here.

No comments: