Resolving 'The server quit without updating PID file' Error After MySQL Installation via Homebrew

Nov 25, 2025 · Programming · 11 views · 7.8

Keywords: MySQL | Homebrew | Permission Issues | PID File | macOS

Abstract: This technical article provides a comprehensive analysis of the common MySQL startup error 'The server quit without updating PID file' encountered after Homebrew installation on macOS. Through in-depth examination of permission configurations, error log analysis, and multiple solution approaches, the article offers step-by-step guidance from simple permission fixes to complete MySQL reinstallation. Special emphasis is placed on InnoDB storage engine directory access permissions and the differences between launchd and mysql.server management approaches.

Problem Background and Error Analysis

After installing MySQL via Homebrew on macOS systems, many developers encounter a typical startup error: ERROR! The server quit without updating PID file (/usr/local/var/mysql/username.local.pid). This error indicates that the MySQL server terminated abnormally during startup and failed to create the process identification file.

Root Cause of Permission Issues

By analyzing error log files at /usr/local/var/mysql/*.err, the specific manifestations of permission problems can be clearly identified. Typical error messages include:

120314 16:30:14  InnoDB: Operating system error number 13 in a file operation.
InnoDB: The error means mysqld does not have the access rights to
InnoDB: the directory.
InnoDB: File name ./ibdata1
InnoDB: File operation call: 'open'.
InnoDB: Cannot continue operation.
120314 16:30:14 mysqld_safe mysqld from pid file /usr/local/var/mysql/janmoesen.local.pid ended

Error code 13 indicates permission denied, specifically that the InnoDB storage engine cannot access the data file directory. This typically occurs when the MySQL service process lacks sufficient permissions to read and write files in the /usr/local/var/mysql/ directory.

Solution 1: Permission Repair

The most direct solution is to modify the ownership and permissions of the MySQL data directory. First, check the current directory permissions:

ls -la /usr/local/var/mysql/

If incorrect permissions are found, use the following command to fix them:

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

In some cases, more permissive settings may be required:

chmod -R 755 /usr/local/var/mysql/

After completing permission repairs, restart the MySQL service:

mysql.server start

Solution 2: Database Initialization Verification

Before attempting any repair measures, it is essential to ensure that the MySQL database has been properly initialized. Use the following command to verify database status:

mysqld --initialize --explicit_defaults_for_timestamp

This step creates necessary system tables and data files, establishing the foundation for normal MySQL operation.

Solution 3: Complete MySQL Reinstallation

If permission repairs and database initialization fail to resolve the issue, consider a complete MySQL reinstallation. Before performing this operation, be sure to back up all important data:

mysqldump -u root -p --all-databases > backup.sql

Then execute the complete reinstallation process:

brew remove mysql
brew cleanup
launchctl unload -w ~/Library/LaunchAgents/homebrew.mxcl.mysql.plist
rm ~/Library/LaunchAgents/homebrew.mxcl.mysql.plist
sudo rm -rf /usr/local/var/mysql
brew install mysql
mysqld --initialize --explicit_defaults_for_timestamp
mysql.server start

Service Management Approach Selection

Homebrew provides two MySQL service management approaches: launchd and mysql.server. Understanding the differences between them is crucial for problem resolution.

launchd is macOS's system-level service manager, configured for automatic startup via plist files:

ln -sfv /usr/local/opt/mysql/*.plist ~/Library/LaunchAgents
launchctl load ~/Library/LaunchAgents/homebrew.mxcl.mysql.plist

mysql.server provides more direct manual control:

mysql.server start
mysql.server stop
mysql.server restart

When encountering permission issues, it is recommended to temporarily use mysql.server for manual management to avoid complexities introduced by launchd's automatic management.

Temporary Cleanup and Restart Solution

In specific circumstances, temporary file cleanup and system restart can be attempted:

cd /usr/local/var/mysql
sudo rm *.err && sudo rm *.pid
sudo reboot
sudo mysql.server start

This approach can remove potentially corrupted files but should be used cautiously, ensuring important data has been backed up.

Preventive Measures and Best Practices

To prevent recurrence of similar issues, the following best practices are recommended:

Conclusion

MySQL startup failures after Homebrew installation typically stem from permission configuration issues. Through systematic error log analysis, permission repairs, and appropriate service management, the The server quit without updating PID file error can be effectively resolved. Developers are advised to attempt solutions in order of complexity, prioritizing permission fixes and resorting to complete reinstallation only when necessary.

Copyright Notice: All rights in this article are reserved by the operators of DevGex. Reasonable sharing and citation are welcome; any reproduction, excerpting, or re-publication without prior permission is prohibited.