电脑技术学习

Mysql故障排除:Starting MySQL. ERROR! Manager of pid-file quit without updating file

dn001

安装完mysql后,启动MYSQL时发现报错,提示如下:
[root@web-server log]# /etc/rc.d/init.d/mysqld start
Starting MySQL. ERROR! Manager of pid-file quit without updating file.

看下日志:
[root@web-server log]# cat alert.log
100811 10:22:57 mysqld_safe Starting mysqld daemon with databases from /usr/local/mysql/data
100811 10:22:57 [Warning] The syntax '--log_slow_queries' is deprecated and will be removed in MySQL 7.0. Please use '--slow_query_log'/'--slow_query_log_file' instead.
/usr/local/mysql/libexec/mysqld: File './mysql-bin.index' not found (Errcode: 13)
100811 10:22:57 [ERROR] Aborting

100811 10:22:57 [Note] /usr/local/mysql/libexec/mysqld: Shutdown complete

100811 10:22:57 mysqld_safe mysqld from pid file /usr/local/mysql/data/web-server.pid ended
100811 10:26:38 mysqld_safe Starting mysqld daemon with databases from /usr/local/mysql/data
100811 10:26:38 [Warning] The syntax '--log_slow_queries' is deprecated and will be removed in MySQL 7.0. Please use '--slow_query_log'/'--slow_query_log_file' instead.
/usr/local/mysql/libexec/mysqld: File './mysql-bin.index' not found (Errcode: 13)
100811 10:26:38 [ERROR] Aborting

100811 10:26:38 [Note] /usr/local/mysql/libexec/mysqld: Shutdown complete

100811 10:26:38 mysqld_safe mysqld from pid file /usr/local/mysql/data/web-server.pid ended
;

在网上找了如下方法,但依旧无法解决:

有人说将/etc/my.cnf里面的 skip federated注释掉即可,但我的my.cnf里压根就没有这一项,还有人说/etc/my.cnf中没有设置datadir=/data/mysql,但我看了这一项已经有了。还有说data/mysql-bin.index没有删除,data/mysql-bin.index是存放日志文件索引的文件,只删除了日志文件而没有对日志的索引文件做处理显然是不行的。但删除data/mysql-bin.index文件,再service mysqld start还是不行。

应该如何解决呢?

今天终于搞定了

mysql编译如下:

CHOST="x86_64-pc-linux-gnu"
CFLAGS="-march=nocona -O3 -pipe"
CXXFLAGS="${CFLAGS}"
./configure \
"--prefix=/usr/local/mysql" \
"--localstatedir=/data/mysql/data" \
"--with-comment=Source" \
"--with-mysqld-user=mysql" \
"--without-debug" \
"--with-big-tables" \
"--with-charset=gbk" \
"--with-collation=gbk_chinese_ci" \
"--with-extra-charsets=all" \
"--with-pthread" \
"--enable-static" \
"--enable-thread-safe-client" \
"--with-client-ldflags=-all-static" \
"--with-mysqld-ldflags=-all-static" \
"--enable-assembler" \
"--with-plugins=all" \
"--without-ndb-debug

make
make install
useradd mysql -d /data/mysql -s/sbin/nologin
/usr/local/mysql/bin/mysql_install_db--user=mysql
cd /usr/local/mysql
chown -R mysql:mysql . 这一步一定要搞清楚,不要照网上的乱抄,到时候启动mysql时会因为目录权限问题而导致出错!谨记。
mkdir -p /data/mysql/data
chown -R mysql /data/mysql/data
cp share/mysql/my-huge.cnf /etc/my.cnf
cp share/mysql/mysql.server/etc/rc.d/init.d/mysqld
chmod 755 /etc/rc.d/init.d/mysqld
chkconfig --add mysqld
/etc/rc.d/init.d/mysqld start
;;
cd /usr/local/mysql/bin
for i in *; do ln -s /usr/local/mysql/bin/$i/usr/bin/$i; done

这样,问题就解决了
[root@web-server local]# service mysqld start
Starting MySQL.