Dulu sewaktu PHP 5 baru di release, pada saat instalasi di Windows XP dengan webserver Apache. Saya mendapati error ” Cannot load mysql extension. Please check your PHP configuration “. Dan sepertinya, kejadian tersebut akan terus berulang pada teman-teman yang ingin mencoba PHP 5 di Windows, karena sudah terbiasa installasi PHP 4 di Windows dan tidak memerlukan pelakuan yang khusus. Berbeda dengan PHP 5 yang ternyata memerlukan perhatian khusus. (dan itu sayangnya para developer PHP tidak mencantumkan perlakuan tersebut di file INSTALL yang ada. Karena file INSTALL yang ada, gak banyak perubahan dari file INSTALL di PHP 4)

Setelah dicari kesono kemari, akhirnya ditemukanlah perlakuan khusus tersebut.


Installation on Windows Systems
The PHP MySQL extension is compiled into PHP.
PHP 5+
MySQL is no longer enabled by default, so the php_mysql.dll DLL must be enabled inside of php.ini. Also, PHP needs access to the MySQL client library. A file named libmysql.dll is included in the Windows PHP distribution and in order for PHP to talk to MySQL this file needs to be available to the Windows systems PATH. See the FAQ titled “How do I add my PHP directory to the PATH on Windows” for information on how to do this. Although copying libmysql.dll to the Windows system directory also works (because the system directory is by default in the system’s PATH), it’s not recommended.

As with enabling any PHP extension (such as php_mysql.dll), the PHP directive extension_dir should be set to the directory where the PHP extensions are located. See also the Manual Windows Installation Instructions. An example extension_dir value for PHP 5 is c:\php\ext

Note: If when starting the web server an error similar to the following occurs: “Unable to load dynamic library ‘./php_mysql.dll'”, this is because php_mysql.dll and/or libmysql.dll cannot be found by the system.

Dan solusinya ada di sini :

14. How do I add my PHP directory to the PATH on Windows?

On Windows NT, 2000, XP and 2003:

  1. Go to Control Panel and open the System icon (Start -> Settings -> Control Panel -> System, or just Start -> Control Panel -> System for Windows XP/2003)
  2. Go to the Advanced tab
  3. Click on the ‘Environment Variables’ button
  4. Look into the ‘System Variables’ pane
  5. Find the Path entry (you may need to scroll to find it)
  6. Double click on the Path entry
  7. Enter your PHP directory ant the end, including ‘;’ before (e.g. ;C:\php)
  8. Press OK and restart your computer

Akhirnya, MySQL dapat diload di PHP 5.

Tetapi hal tersebut tidak terjadi apabila saya bekerja di Linux, karena sudah terbiasa saat installasi menyertakan –with-mysql pada saat kompilasi PHP.

Please follow and like us: