mysqld无法启动:ERROR! The server quit without updating PID file.

#之前最小化源码安装lamp后,mysql好好的,之后又装了yum bind、yum samba、yum vsftp等等,也都正常

#今天新装了yum postfix和源码nagios,mysql却没法启动!

出错:

/etc/init.d/mysql start
 Starting MySQL.. ERROR! The server quit without updating PID file (/var/lib/mysql/www.pid).
#查看/var/lib/mysql/,并没有所谓的www.pid这个文件!


查看log日志:

cat /var/log/mysqld.log |grep ERROR
 2013-04-19 08:20:23 2191 [ERROR] Can't open the mysql.plugin table. Please run mysql_upgrade to create it.
 2013-04-19 08:20:27 2191 [ERROR] Fatal error: Can't open and lock privilege tables: Table 'mysql.user' doesn't exist
#尝试mysql_upgrade,提示错误:
mysql_upgrade
 Looking for 'mysql' as: mysql
 Looking for 'mysqlcheck' as: mysqlcheck
 Running 'mysqlcheck with default connection arguments
 mysqlcheck: unknown option '--fix-db-names'
 FATAL ERROR: Upgrade failed
#查看/usr/local/mysql/data/mysql这个数据库所在的文件夹,里面的文件权限都是mysql:mysql,user表也存在!
ll /usr/local/mysql/data/mysql/user.*
-rw-rw---- 1 mysql mysql 10684 03-19 22:48 /usr/local/mysql/data/mysql/user.frm
-rw-rw---- 1 mysql mysql   624 04-10 13:25 /usr/local/mysql/data/mysql/user.MYD
-rw-rw---- 1 mysql mysql  2048 04-10 14:58 /usr/local/mysql/data/mysql/user.MYI


查看状态:

/etc/init.d/mysql status
 ERROR! MySQL is not running, but lock file (/var/lock/subsys/mysql) exists
#存在这个/var/lock/subsys/mysql文件,删除掉,结果还是不行!

rm -f /var/lock/subsys/mysql


查看配置:

#查看my.cnf文件,只有2行,因为当时可以成功运行,没出过错,所以也就没去配置。
cat /usr/local/mysql/my.cnf |sed 's/#.*$//g'|grep '[^[:blank:]]'
[mysqld]
sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES

解决:

#mysql.user表存在,源码安装时自定义了安装路径,而我又是用/etc/init.d/mysql脚本来启动

#出错原因可能是:init启动脚本找不到路径
#解决办法是:在my.cnf的[mysqld]项目下增加basedir和datadir
vim /usr/local/mysql/my.cnf
[mysqld]
basedir = /usr/local/mysql
datadir = /usr/local/mysql/data

#启动成功!!!

/etc/init.d/mysql start

 Starting MySQL. SUCCESS!


发现新问题:

#mysql里面的password()函数是5.1版本前用的老函数,只能生成16位的序列。。。

mysql>select PASSWORD('mysql');
+-------------------+
| PASSWORD('mysql') |
+-------------------+
| 68d4f47c49a579c9  |
+-------------------+

查笔记

#老老实实的查之前做了什么,拿出昨天的安装笔记

yum install postfix
Dependencies Resolved
==========================================================================
Package                Arch    Version                  Repository   Size
Installing:
 postfix               i386    2:2.3.3-6.el5            base         3.6 M
Installing for dependencies:
 cyrus-sasl            i386    2.1.22-7.el5_8.1         base         1.2 M
 mysql                 i386    5.0.95-5.el5_9           updates      4.9 M
 perl-DBI              i386    1.52-2.el5               base         600 k
Updating for dependencies:
 cyrus-sasl-lib        i386    2.1.22-7.el5_8.1         base         126 k 


#yum“好心”帮我装了mysql!!!!,而且是5.0版的。。。。无语了


解决新问题:
yum remove mysql
#这个命令同时删除mysql、postfix和dovecot三个软件

/etc/init.d/mysql restart

这时select password('mysql');就是41位的了。

你可能感兴趣的:(mysqld无法启动:ERROR! The server quit without updating PID file.)