ERROR: MySQL server PID file could not be found on osX

The following fix helped me resolve MySQL Startup/Restart Problems

phpMyAdmin Screenshot

After swapping my old Harddrive to a new MacBook, I experienced Problems with the MySQL installation.

[ERROR] InnoDB: Unable to lock ./ibdata1, error: 35
ERROR! MySQL server PID file could not be found!

Trying to open some tables resulted in the error above. I was also unable to restart MySQL from the Terminal.

$ sudo /usr/local/mysql/support-files/mysql.server restart
ERROR! MySQL server PID file could not be found!
Starting MySQL.....................................................................
ERROR! The server quit without updating PID file (/usr/local/mysql/data/XXXXXX.pid)

How to resolve this Error

First check for the correct user rights. Move to usr/local/mysql/data and see if all files and folders belong to user _mysql.

If this is not the case change the permission with to user and group mysql.

$ chown -R mysql:mysql usr/local/mysql/data/*

Afterwards try to (re)start apache and MySQL with

$ sudo apachectl start
$ sudo /usr/local/mysql/support-files/mysql.server start

If this fails you may still got an old mysqld process running. Check the Activity-Monitor or type the following command in the console to get the PID number for the process mysqld.

$ ps -ax|grep mysqld

With the correct PID you can kill the process with:

$ sudo kill YOUR_PID_NUMBER

Next try again to start Apache and MySQL.

$ sudo apachectl restart
$ sudo /usr/local/mysql/support-files/mysql.server start
Starting MySQL
.. SUCCESS!

If you experience further errors see the *.err files in the MySQL data folder under /usr/local/mysql/data.