/etc//mysqld 启动和关闭 mysql 报错

时间:2025-03-15 22:28:06

文章目录

      • /etc//mysqld 启动和关闭 mysql 报错
        • 情景描述
        • 原因
        • 解决方案

/etc//mysqld 启动和关闭 mysql 报错

情景描述

按照以下步骤操作

  1. 使用下面的命令将服务脚本放在 /etc// 目录下
shell> cp /usr/local/mysql/support-files/ /etc//mysqld
  1. mysql服务的启动|停止|重启
shell> /etc//mysqld start|stop|restart 

报以下错误

ERROR! MySQL server PID file could not be found!
原因

MySQL 的配置文件未读取到,造成 MySQL 无法获取 PID 文件所在目录(从 datadir 参数处获取到该信息)

shell> /usr/local/mysql/bin/mysql --help | grep 

默认读取 文件的 4 处路径

/etc/ 
/etc/mysql/ 
/usr/local/mysql/etc/ 
~/.
解决方案

可在以下 4 种路径下(建议在 /etc/ 路径下)指定 文件,并配置好 datadir 的路径

/etc/ 
/etc/mysql/ 
/usr/local/mysql/etc/ 
~/.