05.php_pdo引用不恰当libmysql.dll导致Apache崩溃

05.php_pdo引用不恰当libmysql.dll导致Apache崩溃

郑昀 2010 隶属于《07.杂项》小节

现象

在测试环境Windows XP/2003+PHP v5.2.14+Apache v2.2下,使用php_pdo对象试图连接 MySql 数据库服务时,apache的error.log中什么也没报告,httpd.exe 二话不说径直崩溃。

在 php.ini 中注释掉 extension=php_pdo.dll 后,Apache则不再崩溃。

 

解决方法

该环境在 %SYSTEM32% 目录下,曾放置过一个 libmysql.dll 。

经测试,Apache加载的是此路径下的 libmysql.dll 。

由于 libmysql.dll 文件并没有列出版本号,所以只能通过文件大小来判断是哪一个版本的。

一般,PHP v5.2.14自带的 libmysql.dll 文件大小是2,076KB。

MySql v5.0 自带的则是1,531KB。

MySql v5.5 Cluster自带的是2,703KB。

MySql v5.5 自带的是4,168KB,并且已经有了版本号:5.5.5.0。

怀疑该环境 %SYSTEM32% 目录下的 libmysql.dll 文件与Apache v2.2+PHP v5.2.14不兼容,所以用PHP自带的 libmysql.dll 文件替换,遂成。

 

参考说法

http://bugs.php.net/bug.php?id=46289 BUG报告道:

[2009-06-22 01:53 UTC] ramin dot farmani at gmail dot com

Hi

similarly my httpd.exe crashed when i runnig a site wroten by Yii framework it's seem we have a big problem in php_pdo_mysql library I using php 5.2.10

[2009-09-02 01:07 UTC] Parad0X dot UA at gmail dot com

I was able to fix this by removing MYSQL from Windows' PATH env setting. Looks like when PHP is looking for libmysql.dll it uses the first one it finds in mysql\bin and it's not quite compatible.

Or you can try to add php to the path before mysql.

I hope that helps.

【注:此处建议,在系统变量PATH中,把PHP的目录放在MySql\bin目录前。】

[2009-09-02 07:45 UTC] pajoye@php.net

Ok, it was then the classic case where MySql's libmysql DLL was used instead of the version bundled with PHP. We already have many bogus reports about this issue and your solution is the right one (as explain in the other reports).

【注:此处认为这是一个经典的场景,把MySql自带的libmysql替换PHP自带的,导致不兼容悲剧。】

posted @ 2010-10-15 18:21  老兵笔记  阅读(3055)  评论(0编辑  收藏  举报