You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

HighSierra Mac用brew装MySQL5.7.21启动失败:未更新PID文件报错求助

Fixing "ERROR! The server quit without updating PID file" for MySQL 5.7.21 on High Sierra (Homebrew Install)

Hey there, let’s dig into this MySQL startup headache you’re dealing with. You’ve already tried the common fixes—setting wide permissions, deleting the error file, following that popular guide—but let’s go through some targeted, safer steps that often resolve this stubborn issue.


First: Try Homebrew’s Service Manager Instead

Homebrew’s built-in service tool handles path and permission consistency better than the raw mysql.server command. Let’s give it a shot:

# Check current MySQL service status
brew services list
# Start MySQL with brew services (use mysql@5.7 for version-specific installs)
brew services start mysql@5.7

If you’re on an older Homebrew version, omit the @5.7 suffix if needed.

Fix Permissions Safely (Skip the 777 Risk)

Giving full 777 permissions to your entire /usr/local/var/mysql folder is a security no-no. Instead, ensure the directory is owned by the default MySQL system user:

# Set ownership to the _mysql system user/group
sudo chown -R _mysql:_mysql /usr/local/var/mysql
# Set secure, appropriate directory permissions
sudo chmod -R 755 /usr/local/var/mysql

Now try starting MySQL again with mysql.server start.

Check for Bad Config in my.cnf

MySQL 5.7 is picky about config settings. A misconfigured my.cnf file often causes silent startup failures. Let’s rule this out:

  1. Look for custom config files in these locations: /etc/my.cnf, /usr/local/etc/my.cnf, or ~/.my.cnf
  2. Temporarily rename the file to disable it:
    sudo mv /etc/my.cnf /etc/my.cnf.bak
    
  3. Try starting MySQL again. If it works, you can debug the old config line by line to find the culprit (common issues include mismatched innodb_log_file_size values).

Read the Error Log for Clues

Even after deleting the old .err file, MySQL generates a new one when you attempt to start it. Let’s pull the latest error details:

tail -n 50 /usr/local/var/mysql/myMac.err

This log will tell you exactly why the server quit—whether it’s a corrupted table, missing directory, or permission issue with a specific file. For example, if it says "Can't create/write to file", you know to fix permissions on that specific path.

Kill Stuck Zombie Processes

Sometimes a leftover MySQL process holds onto resources, preventing a fresh start. Let’s hunt it down:

# List all MySQL-related processes
ps aux | grep mysql
# Kill the stuck process (replace <PID> with the process ID from the output)
sudo kill -9 <PID>

Then try starting MySQL again.

Last Resort: Reinstall MySQL Cleanly

If nothing else works, a clean reinstall often clears up hidden issues:

# Stop any running MySQL services
brew services stop mysql@5.7
# Uninstall the current version
brew uninstall mysql@5.7
# Remove all leftover files
sudo rm -rf /usr/local/var/mysql
sudo rm /usr/local/etc/my.cnf
# Reinstall the specific 5.7.21 version
brew install mysql@5.7.21
# Initialize MySQL with the correct system user
mysqld --initialize --user=_mysql --basedir=/usr/local/Cellar/mysql@5.7.21/5.7.21 --datadir=/usr/local/var/mysql
# Start the service
brew services start mysql@5.7.21

If none of these steps work, share the latest error log snippet from /usr/local/var/mysql/myMac.err—that’ll help narrow down the exact issue.

内容的提问来源于stack exchange,提问作者frabis

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.22 09:19:20