The server quit without updating PID file 报错

本文详细描述了一种解决MySQL启动时出现“服务器在未更新PID文件的情况下退出”错误的方法,涉及卸载并清理旧版本,删除相关配置文件及目录,重新安装MySQL并设置启动脚本。

mysql.server start

报错:The server quit without updating PID file (/usr/local/var/mysql/zhangzhenxingdeMacBook-Pro.local.pid).

最后还是重新安装!!以前数据库内容丢失。

 

I think one can end up in this position with older versions of mysql already installed. I had the same problem and none of the above solutions worked for me. I fixed it thus:

Used brew’s remove & cleanup commands, unloaded the launchctl script, then deleted the mysql directory in /usr/local/var , deleted my existing /etc/my.cnf (leave that one up to you, should it apply) and launchctl plist

Updated the string for the plist. Note also your alternate security script directory will be based on which version of MySQL you are installing.

Step-by-step:

1 brew remove mysql
2 
3 brew cleanup
4 
5 launchctl unload -w ~/Library/LaunchAgents/homebrew.mxcl.mysql.plist
6 
7 rm ~/Library/LaunchAgents/homebrew.mxcl.mysql.plist
8 
9 sudo rm -rf /usr/local/var/mysql

 

I then started from scratch:

  1. installed mysql with brew install mysql
  2. ran the commands brew suggested:
    1 unset TMPDIR
    2 
    3 mysql_install_db --verbose --user=`whoami` --basedir="$(brew --prefix mysql)" --datadir=/usr/local/var/mysql --tmpdir=/tmp

     

  3. Start mysql with mysql.server start command, to be able to log on it
  4. Used the alternate security script:
    /usr/local/Cellar/mysql/5.5.10/bin/mysql_secure_installation

     

  5. Followed the launchctl section from the brew package script output such as,
    #start
    launchctl load -w ~/Library/LaunchAgents/homebrew.mxcl.mysql.plist
    
    #stop
    launchctl unload -w ~/Library/LaunchAgents/homebrew.mxcl.mysql.plist

     

  6. Boom.

Hope that helps someone!

转载于:https://www.cnblogs.com/linuxOS/p/6815923.html

MySQL 启动时报错 `The server quit without updating PID file` 通常表示 MySQL 服务在启动过程中意外终止,未能成功创建或更新 PID 文件。PID 文件用于记录 MySQL 主进程的进程 ID,系统通过该文件判断 MySQL 是否正在运行。以下是常见的解决方法: ### 1. 检查数据目录权限 MySQL 需要对数据目录具有读写权限。如果权限配置不当,可能导致 MySQL 无法写入 PID 文件。 ```bash chown -R mysql:mysql /var/lib/mysql chmod -R 755 /var/lib/mysql ``` 确保 `datadir` 配置路径下的所有文件和目录权限正确[^3]。 ### 2. 检查 PID 文件路径是否存在 MySQL 期望的 PID 文件路径可能不存在,需要手动创建相应的目录结构。 ```bash mkdir -p /var/run/mysqld chown mysql:mysql /var/run/mysqld ``` 确保 `pid-file` 配置指向的目录存在并具有正确权限[^3]。 ### 3. 检查 MySQL 是否已运行 如果 MySQL 已经在运行,再次启动时会因 PID 文件已被占用而失败。可以通过以下命令检查: ```bash ps aux | grep mysqld ``` 如果发现已有 `mysqld` 进程,可以尝试先停止服务再启动: ```bash systemctl stop mysql systemctl start mysql ``` ### 4. 检查 MySQL 配置文件 在 `my.cnf` 或 `mysqld.cnf` 中确认 `pid-file` 和 `datadir` 的配置是否一致,并确保路径有效。例如: ```ini [mysqld] pid-file = /var/run/mysqld/mysqld.pid datadir = /var/lib/mysql ``` 如果配置路径不一致,可能导致 MySQL 无法正确写入 PID 文件[^1]。 ### 5. 检查磁盘空间和文件系统 如果磁盘空间已满或文件系统损坏,MySQL 可能无法写入 PID 文件。使用以下命令检查磁盘空间: ```bash df -h ``` 若磁盘空间不足,清理不必要的文件或扩展磁盘容量[^4]。 ### 6. 检查日志文件 MySQL 日志文件通常能提供更详细的错误信息,帮助定位问题。日志路径可以在配置文件中找到: ```ini [mysqld] log_error = /var/log/mysql/error.log ``` 查看日志内容: ```bash tail -f /var/log/mysql/error.log ``` 日志中可能包含 PID 文件创建失败的具体原因[^4]。 ### 7. 重新初始化 MySQL 数据目录 如果数据目录损坏,可以尝试重新初始化 MySQL 数据目录: ```bash mysqld --initialize --user=mysql ``` 该命令会生成新的数据目录和默认的 `mysql` 数据库,同时创建新的 PID 文件路径。 ### 8. 使用 `systemctl` 或 `service` 管理 MySQL 某些系统使用 `systemctl` 管理服务,直接执行 `mysqld` 可能导致 PID 文件路径不一致。建议使用以下命令管理 MySQL: ```bash systemctl start mysql ``` 或 ```bash service mysql start ``` 这样可以确保服务管理器与 MySQL 的 PID 文件路径保持一致[^2]。 ---
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符  | 博主筛选后可见
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值