My Windows crashed (blue screen) one day while I was updating a WordPress website on MAMP.

When the computer rebooted, MySQL would not restart, and I spent the next 4 hours sweating, trying to get it back up. My last database backup was 2 weeks old.

This article is particularly for people on Windows who have tried the other option first, that is everywhere on StackOverflow. The other option is:

  • delete ib_logfile0 and ib_logfile1 and start MySQL

That seemed to fix MySQL for lots of people on StackOverflow, but not for me! The inno_db_force_recovery suggestion also DID NOT work for me – and I suggest you try my less potentially destructive option first.

I started MySQL from a console window to troubleshoot why MySQL wouldn’t start. I’m going to explain how to do that, but you can also skip straight to trying what fixed my MySQL.

Starting MySQL from console (Windows)

  1. Copy the config file my.ini from C:\MAMP\conf\mysql to C:\MAMP\bin\mysql (otherwise command line service will have no config)
  2. Start Command Prompt with Run as administrator (if you don’t run as administrator, the service may not start due to not being able to log to Event Viewer). (Press Windows+R to open the “Run” box. Type “cmd” into the box and then press Ctrl+Shift+Enter to run the command as an administrator.
    Run as administrator
  3. In your command prompt, change directory to C:\MAMP\bin\mysql\bin (cd \MAMP\bin\mysql\bin)
  4. Run mysqld –console
  5. Read the output to look for clues.
  6. (If you need to quit, type quit)

In my case, the clue pointed to corrupted log files, log file not found, and the log file name read like a log event.

So I looked to see if there was a way to purge the logs.

Log files and MySQL

The default naming for log files in MySQL on Windows is:

mysql-bin.000001
mysql-bin.000002
mysql-bin.000003

Mine was up to

mysql-bin.000118

There is also a file called mysql-bin.index

The “bin” stands for Binary Logs. I think a key purpose of these logs is to assist replication in multi-server environments. They are NOT your data and tables.

At first, I tried just deleting all logs, but when I did this, although MySQL would start up again, it looked like all my tables were empty, which was a disaster. Don’t worry though! We can get rid of all the logs and get around a corrupted log.

Resetting the log files

Open up my.ini in C:\MAMP\conf\mysql (note: this is your MAMP config, not the command line one – if you are testing with command line, you need to edit the C:\MAMP\bin\mysql one)

Search for log-bin and try to put the following lines in that part of the file.

Save the file, and then try to start your MySQL.

If it’s all working again, you can clean out your old log files! For me, that was mysql-bin.* – over 400 MB of logs.

Copy to Clipboard