mysql错误-The server quit without updating PID file

说明:尽量不要用root用户安装和启动mysql

问题示例

  • 原因:一般是root用户执行导致,如果MySQL是root以外用户安装的,则用安装的用户执行不会出差
  • 固执:这里就是要用root执行。
[root@hadoop01 mysql]# service mysql start
Starting MySQL.Logging to '/opt/mysql/data/hadoop01.err'.
 ERROR! The server quit without updating PID file (/opt/mysql/data/hadoop01.pid).


[root@hadoop01 mysql]# ./support-files/mysql.server start
Starting MySQL.Logging to '/opt/mysql/data/hadoop01.err'.
 ERROR! The server quit without updating PID file (/opt/mysql/data/hadoop01.pid).

解决问题

  1. support-files目录下的mysql.server 执行的是 mysqld_safe 而不是 mysqld
  2. mysqld_safe 默认不能用root用户执行
  3. 想要用root用户执行则,必须在 $bindir/mysqld_safe 后加上 --user=root
then
  mysqld_pid_file_path=$datadir/`hostname`.pid
else
  case "$mysqld_pid_file_path" in
    /* ) ;;
    * )  mysqld_pid_file_path="$datadir/$mysqld_pid_file_path" ;;
  esac
fi

case "$mode" in
  'start')
    # Start daemon

    # Safeguard (relative paths, core dumps..)
    cd $basedir

    echo $echo_n "Starting MySQL"
    if test -x $bindir/mysqld_safe
    then
      # Give extra arguments to mysqld with the my.cnf file. This script
      # may be overwritten at next upgrade.
      $bindir/mysqld_safe --user=root --datadir="$datadir" --pid-file="$mysqld_pid_file_path" $other_args >/dev/null &
      wait_for_pid created "$!" "$mysqld_pid_file_path"; return_value=$?

      # Make lock for RedHat / SuSE
      if test -w "$lockdir"
      then
        touch "$lock_file_path"
      fi

      exit $return_value
    else
      log_failure_msg "Couldn't find MySQL server ($bindir/mysqld_safe)"
    fi
    ;;

结果

  • 结果:service mysql start还是失败。
  • 原因:之前的mysql没改
[root@hadoop01 mysql]# ./support-files/mysql.server start
Starting MySQL.Logging to '/opt/mysql/data/hadoop01.err'.
 SUCCESS! 

[root@hadoop01 mysql]# service mysql start
Starting MySQL. ERROR! The server quit without updating PID file (/opt/mysql/data/hadoop01.pid).

## 覆盖后
[root@hadoop01 etc]# cp /opt/mysql/support-files/mysql.server /etc/init.d/mysql

[root@hadoop01 etc]# service mysql start
Starting MySQL. SUCCESS!

如果没有成功

查看hadoop01.err错误日

posted @ 2024-08-20 17:23  疯子110  阅读(329)  评论(0编辑  收藏  举报