081007 15:08:53 mysqld started
081007 15:08:53 InnoDB: Operating system error number 13 in a file operation.
InnoDB: The error means mysqld does not have the access rights to
InnoDB: the directory.
InnoDB: File name ./ibdata1
InnoDB: File operation call: 'open'.
InnoDB: Cannot continue operation.
081007 15:08:53 mysqld ended
初步分析是权限问题,从网上搜了一些资料,以下是比较完整的说明,但没有具体解决方案
If InnoDB
prints an operating system error
during a file operation, usually the problem has one of the
following causes:
You did not create the
InnoDB
data file directory or theInnoDB
log directory.mysqld does not have access rights to create files in those directories.
mysqld cannot read the proper
my.cnf
ormy.ini
option file, and consequently does not see the options that you specified.The disk is full or a disk quota is exceeded.
You have created a subdirectory whose name is equal to a data file that you specified, so the name cannot be used as a filename.
There is a syntax error in the
innodb_data_home_dir
orinnodb_data_file_path
value.
If something goes wrong when InnoDB
attempts
to initialize its tablespace or its log files, you should delete
all files created by InnoDB
. This means all
ibdata
files and all
ib_logfile
files. In case you have already
created some InnoDB
tables, delete the
corresponding .frm
files for these tables
(and any .ibd
files if you are using
multiple tablespaces) from the MySQL database directories as
well. Then you can try the InnoDB
database
creation again. It is best to start the MySQL server from a
command prompt so that you see what is happening.
后来我在mysql目录(/usr/local/mysql)下执行命令:chown -R root:mysql *。依然启动失败,不过错误变成了如下内容:
081008 15:03:10 mysqld started
InnoDB: Warning: an inconsistent page in the doublewrite buffer
InnoDB: space id 2999620347 page number 5, 0'th page in dblwr buf.
081008 15:03:11 InnoDB: Started
081008 15:03:11 Fatal error: Can't open privilege tables: Can't find file: './mysql/host.frm' (errno: 13)
搜到的资料同样将其解释为权限问题,于是执行命令:chown -R mysql:root /var/lib/mysql/mysql。
但启动仍然失败,错误也相同。后来才知道要重建nysql_install_db,再mysqld_safe。即要执行如下命令:bin/mysql_install_db --user=mysql(这里的mysql为用户名)。再启动mysql,成功