Mysql启动失败问题解决

当MySQL启动时遇到操作系统错误,通常是因为数据文件目录未创建、权限不足、配置文件读取错误、磁盘空间满或配额超限等问题。解决方法包括删除由mysqld创建的文件,检查权限,特别是对数据库目录的读写权限,以及在必要时重新初始化表空间和日志文件。文中详细描述了在执行chown命令和mysql_install_db后解决MySQL启动失败的问题。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

 最近在实验中要架设RUBiS进行实验,需要apache、jboss和mysql三层结构。开始时,mysql一直没有问题,但这周一却发现mysql启动失败。/var/log/mysqld.log显示如下错误:

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 the InnoDB log directory.

  • mysqld does not have access rights to create files in those directories.

  • mysqld cannot read the proper my.cnf or my.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 or innodb_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,成功

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值