MySQL - How to fix the server quit without updating PID file error when starting

Some suggestions to fix the server quit without updating PID file error when starting MySQL server

Posted on September 04, 2021


When you try to start MySQL server from the terminal, you may get an error message as shown below:

$ sudo /usr/local/mysql/support-files/mysql.server start
Starting MySQL
.. ERROR! 
The server quit without updating PID file (/usr/local/mysql/data/nts-mac.pid).

This tutorial will try to help you to fix the error above and start your MySQL server successfully.

Before you try to fix the error, please don’t forget to create a backup of your MySQL database before trying any of the suggested solutions below.

I’m not responsible for any loss of data as you try to fix this error.

Fix MySQL server quit without updating PID file by killing any running processes

The PID (process identification) file is used by MySQL server to store the process ID number. When you need to run MySQL related commands, the PID file is needed to execute the command properly.

For example, you use the PID file when you want to stop the MySQL server. This is why when you run the mysql.server stop command when there’s no running MySQL instance, the response would be like this:

$ sudo /usr/local/mysql/support-files/mysql.server stop
ERROR! MySQL server PID file could not be found!

In the MySQL error above, the PID file could not be found because it has been deleted when MySQL server stops running previously.

Some common causes that cause the server to quit without updating the PID file are as follows:

  • You upgraded your MySQL version to the latest version
  • Your MySQL service didn’t stop properly the last time it was running
  • There’s already a running mysqld process that’s using a different PID file name.

In my local MySQL server, the third case happens because I started MySQL server using the MySQL Preference Pane that comes bundled with MySQL server installation file for Mac:

When I started the server using the Preference Pane, MySQL generates a PID file named mysqld.local.pid in the /usr/local/mysql/data/ folder.

When I tried to start the server again using the terminal, MySQL tries to find the nts-mac.pid file, which is generated when MySQL is started from the terminal (nts-mac is the name of my Mac computer)

The PID file name mismatch causes MySQL to respond with “the server quit without updating PID file” above.

To fix the error, I needed to stop the currently running MySQL thread from the Preferences Pane before running the mysql.server start command again.

Now you may not be using MySQL Preferences Pane, but it’s possible that you have a MySQL process running in your computer or Linux server that uses a different PID file name than the one generated by the terminal.

To check if there are running MySQL processes in your computer, you can run the ps -e | grep mysql command from your terminal.

Here’s the output from my computer:

$ ps -e | grep mysql 
24836 ttys001    0:00.03 /bin/sh /usr/local/mysql/bin/mysqld_safe
24920 ttys001    0:01.04 /usr/local/mysql/bin/mysqld
24946 ttys001    0:00.01 grep mysql

The result tells me that there are running mysqld processes on my computer. If you found the same in your computer, then you need to kill the running process using one by one using the kill -9 <PID> command.

The PID code number is the first number on the left, so in my case, they are 24836 and 24920:

$ kill -9 24836
$ kill -9 24920

With that, there should be no running MySQL process on your computer. You can now try to start the MySQL server again:

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

Now the MySQL server should be able to start and run properly.

Fix MySQL server by changing the ownership of MySQL data directory

When you install MySQL server on your computer or server, the data/ directory is generated by the installer to store your data, including the PID file.

The data directory must be owned by _mysql in order for MySQL instance to work properly, so one possible cause of the PID file not updated error is that the data/ directory somehow got owned by a different user.

You can check this by running the ls -la command from the terminal to check the owner of the files in your mysql/ directory:

ls -la /usr/local/mysql/

Here’s the result from my computer:

drwxr-xr-x  13 root    wheel      416 Aug 15 21:34 .
drwxr-xr-x  20 root    wheel      640 Aug 15 21:34 ..
-rw-r--r--   1 root    wheel   276551 Jul  1 14:53 LICENSE
-rw-r--r--   1 root    wheel      666 Jul  1 14:53 README
drwxr-xr-x  35 root    wheel     1120 Aug 15 21:34 bin
drwxr-x---  59 _mysql  _mysql    1888 Sep  4 18:03 data
drwxr-xr-x   5 root    wheel      160 Jul  1 16:42 docs
drwxr-xr-x  16 root    wheel      512 Jul  1 16:42 include
drwxr-x---   3 _mysql  _mysql      96 Sep  4 18:02 keyring
drwxr-xr-x  17 root    wheel      544 Aug 15 21:34 lib
drwxr-xr-x   4 root    wheel      128 Jul  1 16:42 man
drwxr-xr-x  34 root    wheel     1088 Jul  1 16:42 share
drwxr-xr-x   5 root    wheel      160 Jul  1 16:42 support-files

If you have another owner than _mysql for the data/ directory, then you need to run the chown command to change the owner of the directory.

The following command will change the owner of the data/ directory along with all files and subdirectories below it:

sudo chown -R _mysql:_mysql /usr/local/mysql/data

Next, run the ls -la again and you should see the data/ directory owner got changed to _msql in the terminal output.

You can try to run the MySQL server again now.

Fix MySQL server quit by reinstalling the server

If the solutions above fail, then I can only recommend you to try and reinstall MySQL server on your computer.

When installing MySQL server, please use the official installation file provided by mysql.com.

While you may want to install the server from package managers like Homebrew, Chocolatey, or any other Linux package repository, the installation from these third-party providers may cause unnecessary problems like wrong files or folders owner assignments.

If you don’t want to reinstall the server yet, then you may find other suggestions in StackOverflow. I only write what works for me in this tutorial.

And those are my suggestions for fixing the server quit without updating PID file error in MySQL database server. Good luck fixing the error! 👍

See also:

Level up your programming skills

I'm sending out an occasional email with the latest programming tutorials. Drop your email in the box below and I'll send new stuff straight into your inbox!

No spam. Unsubscribe anytime.