MySQL Server Startup Error

System:
OS X Mavericks (10.9.3)
MySQL Server (5.6.19)

Symptom:
Ever since installing MySQL using Homebrew, MySQL would not start up properly on a hard reboot. When I try to start MySQL manually using mysql.server start, Terminal outputs

. ERROR! The server quit without updating PID file (/usr/local/var/mysql/XXXXXX.pid).

General Solution:
Check the error file at /usr/local/var/mysql/XXXXXX.err to see what’s going on, and then try to fix it. It is most likely caused by the improper shutdown’s impact on a InnoDB database.

Specific Solution to InnoDB Error:

  1. Create or edit the MySQL configuration file:
    $ nano /etc/my.cnf
  2. Add or edit the mysqld section:
    [mysqld]
    innodb_force_recovery = 1
  3. Start the server:
    mysql.server start
  4. It should start up without errors. If not, read about forcing InnoDB recovery in the MySQL documentation, and then increase the number after the innodb_force_recovery attribute. Disclaimer: I am not responsible for any data loss caused by following the advice on this page (or this site for that matter). Use at your own risk.
  5. Stop the server:
    mysql.server stop
  6. Edit the MySQL configuration file again, and reset the innodb_force_recovery attribute:
    $ nano /etc/my.cnf
    innodb_force_recovery = 0
  7. Restart the server:
    mysql.server start