MySQL server startup error 'The server quit without updating PID file'

Try to find your log file with suffix ".err". There should be more information. It might be in:

/usr/local/var/mysql/your_computer_name.local.err

It's probably a problem with permissions

  1. Check if any MySQL instance is running

    ps -ef | grep mysql
    

    If yes, you should stop it, or kill the process:

    kill -9 PID
    

    where PID is the number displayed next to the username on the output of the previous command

  2. Check ownership of /usr/local/var/mysql/

    ls -laF /usr/local/var/mysql/
    

    If it is owner by root, you should change it to mysql or your_user

    sudo chown -R mysql /usr/local/var/mysql/
    

Follow the instructions from brew install mysql.

Set up databases to run as your user account with:

For MySQL 5.x:

unset TMPDIR
mysql_install_db --verbose --user=`whoami` --basedir="$(brew --prefix mysql)" --datadir=/usr/local/var/mysql --tmpdir=/tmp

To set up base tables in another folder, or use a different user to run mysqld, view the help for mysqld_install_db:

mysql_install_db --help

And view the MySQL documentation:

  • 4.4.3 mysql_install_db — Initialize MySQL Data Directory
  • 2.10.4 Securing the Initial MySQL Accounts

For MySQL 8.x:

unset TMPDIR
mysqld --initialize-insecure --log-error-verbosity --user=`whoami` --basedir="$(brew --prefix mysql)" --datadir=/usr/local/var/mysql --tmpdir=/tmp

Make sure the data directory /usr/local/var/mysql above is empty. Back it up if necessary.

To run as, for instance, user "mysql", you may need to sudo:

sudo mysql_install_db ...options...

Start mysqld manually with:

mysql.server start

Note: if this fails, you probably forgot to run the first two steps up above


I had the same issue on my Mac machine (correctly followed all the installation steps suggested by brew install).

Deleting the error file fixed it for me:

sudo rm -rf /usr/local/var/mysql/dev.work.err (dev.work is my hostname)

This worked because dev.work.err was owned by _mysql:wheel instead of my own username. CHOWN-ing the error file would have probably fixed it as well.


After rebooting I had the same issue. Here is how I fixed it:

sudo chown -R _mysql /usr/local/var/mysql

This worked for me...

Check all of the MySQL processes running:

$ ps aux | grep mysql

USER     PID    %CPU  %MEM 
_mysql   5970   0.0   0.4 ...

Then kill all the processes listed from the above command using the following:

$ sudo kill -9 [PID]

Replace [PID] with the individual PID from the list above, e.g. 5970.

Do that for all of the lines you see with the first command.

Then you can startup your MySQL server again:

mysql.server start