【问题解决】MYSQL 服务无法启动,错误日志:InnoDB: .\ibdata1 must be writable

本文解决了一个常见的MySQL5.7服务无法启动的问题,通过终止mysqld进程并删除ib_logfile0和ib_logfile1文件,然后重新启动MySQL服务。问题在于InnoDB引擎的日志文件权限问题。

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

问题解决

这几天安装MYSQL 5.7版本的时候,出现了服务无法启动的问题,尝试了各种修改配置文件my.ini的方法都不行,查看到错误日志,一般错误日志在C:\Program Files\MySQL\MySQL Server 5.7\data\xxx.err,其中看到错误提示为:

2017-05-03T17:14:56.155066Z 0 [ERROR] InnoDB: .\ibdata1 must be writable
2017-05-03T17:14:56.155066Z 0 [ERROR] InnoDB: The system tablespace must be writable
2017-05-03T17:14:56.375466Z 0 [ERROR] Plugin 'InnoDB' init function returned error.
2017-05-03T17:14:56.375466Z 0 [ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE failed.
2017-05-03T17:14:56.375466Z 0 [ERROR] Unknown/unsupported storage engine: InnoDB
2017-05-03T17:14:56.375466Z 0 [ERROR] Aborting

MYSQL没有权限写入.\ibdata1文件,使用管理者取得该文件的权限后也没有效果,偶然看到有位大佬的修改方法:

解决方法:
1、打开任务管理器终止mysqld进程;
2、打开mysql安装目录的data文件夹,删除以下2个文件:ib_logfile0ib_logfile1
3、重新启动mysql

成功解决服务无法启动的问题,但是为什么可以这样解决呢,大佬没有给出解释,接下来几天要好好看看MYSQL文件的用途,试试看能不能给个解释

原因分析

MySQL 文件结构

MySQL文件包括MySQL所建数据库文件和MySQL所用引擎创建的数据库文件。
.frm 文件与操作系统和数据库引擎无关,都有这么个与表名同名文件。

MyISAM引擎的文件:

  • .myd 即 my data,表数据文件
  • .myi 即my index,索引文件
  • .log 日志文件。

InnoDB引擎的文件:

  • 采用表空间(tablespace)来管理数据,存储表数据和索引,
  • InnoDB数据库文件(即InnoDB文件集,ib-file set):
  • ibdata1、ibdata2等:系统表空间文件,存储InnoDB系统信息和用户数据库表数据和索引,所有表共用。
  • .ibd文件:单表表空间文件,每个表使用一个表空间文件(file per table),存放用户数据库表数据和索引。
  • Redo日志文件: ib_logfile0、ib_logfile1

MySQL社区手册

MySQL INNODB启动配置

The directory path to the InnoDB redo log files, whose number is specified by innodb_log_files_in_group. If you do not specify any InnoDB log variables, the default is to create two files named ib_logfile0 and ib_logfile1 in the MySQL data directory. Log file size is given by the innodb_log_file_size system variable.参考

InnoDB 在启动时需要配置LOG File的目录,如果没有制定目录,则会在MySQL Data目录下创建2个日志文件ib_logfile0 and ib_logfile1,在创建的时候需要确保MYSQL拥有对该目录的权限。

方案解释

原来的文件不是MYSQL生成,MYSQL 没有相应的权限,但是删除后,后来MYSQL自己新建的文件,能够保持权限???需要验证

D:\Mysql\bin>mysqld --skip-grant-tables --console 2025-03-16T05:33:30.362796Z 0 [System] [MY-015015] [Server] MySQL Server - start. 2025-03-16T05:33:30.535298Z 0 [Warning] [MY-010915] [Server] 'NO_ZERO_DATE', 'NO_ZERO_IN_DATE' and 'ERROR_FOR_DIVISION_BY_ZERO' sql modes should be used with strict mode. They will be merged with strict mode in a future release. 2025-03-16T05:33:30.535705Z 0 [System] [MY-010116] [Server] D:\Mysql\bin\mysqld.exe (mysqld 9.2.0) starting as process 28996 2025-03-16T05:33:30.538219Z 0 [Warning] [MY-013242] [Server] --character-set-server: 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. 2025-03-16T05:33:30.560258Z 1 [System] [MY-013576] [InnoDB] InnoDB initialization has started. 2025-03-16T05:33:30.561797Z 1 [ERROR] [MY-012271] [InnoDB] The innodb_system data file 'ibdata1' must be writable 2025-03-16T05:33:30.561919Z 1 [ERROR] [MY-012278] [InnoDB] The innodb_system data file 'ibdata1' must be writable 2025-03-16T05:33:30.562082Z 1 [ERROR] [MY-010334] [Server] Failed to initialize DD Storage Engine 2025-03-16T05:33:30.562492Z 0 [ERROR] [MY-010020] [Server] Data Dictionary initialization failed. 2025-03-16T05:33:30.562634Z 0 [ERROR] [MY-010119] [Server] Aborting 2025-03-16T05:33:30.563777Z 0 [System] [MY-010910] [Server] D:\Mysql\bin\mysqld.exe: Shutdown complete (mysqld 9.2.0) MySQL Community Server - GPL. 2025-03-16T05:33:30.563939Z 0 [System] [MY-015016] [Server] MySQL Server - end.
03-17
评论 12
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值