CLI has stopped working


CLI has stopped working” is an error that you may encounter when running command-line PHP scripts in Windows.  This has been reported frequently by CakePHP users when their “bake” scripts crash.  My particular experience with this issue occurred while running PHPUnit tests from the command line.

The top search result as well as others indicates that this is a problem with php_mysqli.dll however none of the suggestions on this page helped me.  An experts exchange post indicates that the problem is with libmysql.dll, however I didn’t know where to download the replacement for libmysql.dll.  It turns out that I already had it and the following solves the problem on My Vista and Windows 2003 boxes:

Copy From: C:\Program Files\MySQL Server 5.0\bin\libmySQL.dll

Paste To: C:\Program Files\PHP\ (overwrite the original)

This assumes you installed MySQL and PHP to their default locations.  If not, then use the correct paths for your particular setup.

Prior to this fix, my unit tests were causing the “CLI has stopped working” error at least 50% of the time.  Since replacing the dll file I haven’t seen the error.

  1. #1 by Jason on July 13th, 2008

    UPDATE – I recently got the CLI error again so this doesn’t solve the problem completely. However, it did radically decrease the number of times I get it. I’ve since discovered that the CLI happens when using the PEAR library Spreadsheet::Writer – I doubt that library is the cause, but something in there triggers the CLI error frequently.

  2. #2 by John on July 23rd, 2008

    This hasn’t helped at all for me. I have replaced libmysql.dll and php_mysqli.dll to no avail. What about php_mysql.dll?

  3. #3 by John on July 23rd, 2008

    I tell a lie, I have got it working. This time I completed replaced the ext directory with the latest from the PHP zip, and it works. I don’t think the problem was libmysql.dll

  4. #4 by Jason on July 26th, 2008

    Hey John, what version did you copy? I thought I had fixed the problem for a while – i did not see any errors, but then it turns out it wasn’t totally fixed. The dll update definitely had a positive effect, but I can say for sure it wasn’t 100%.

(will not be published)

  1. No trackbacks yet.