1. 报错环境描述:RHEL7下,在删除了以MariaDB-compat方式安装的mariadb后,再新装数据库无法启动,相关报错与问题信息如下:
210109 14:39:15 mysqld_safe mysqld from pid file /var/run/mariadb/mariadb.pid ended 210109 14:40:37 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql 210109 14:40:37 [Note] /usr/libexec/mysqld (mysqld 5.5.68-MariaDB) starting as process 3044 ... 210109 14:40:37 InnoDB: The InnoDB memory heap is disabled 210109 14:40:37 InnoDB: Mutexes and rw_locks use GCC atomic builtins 210109 14:40:37 InnoDB: Compressed tables use zlib 1.2.7 210109 14:40:37 InnoDB: Using Linux native AIO 210109 14:40:37 InnoDB: Initializing buffer pool, size = 128.0M 210109 14:40:37 InnoDB: Completed initialization of buffer pool InnoDB: Error: checksum mismatch in data file ./ibdata1 210109 14:40:37 InnoDB: Could not open or create data files. 210109 14:40:37 InnoDB: If you tried to add new data files, and it failed here, 210109 14:40:37 InnoDB: you should now edit innodb_data_file_path in my.cnf back 210109 14:40:37 InnoDB: to what it was, and remove the new ibdata files InnoDB created 210109 14:40:37 InnoDB: in this failed attempt. InnoDB only wrote those files full of 210109 14:40:37 InnoDB: zeros, but did not yet use them in any way. But be careful: do not 210109 14:40:37 InnoDB: remove old data files which contain your precious data! 210109 14:40:37 [ERROR] Plugin 'InnoDB' init function returned error. 210109 14:40:37 [ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE failed. 210109 14:40:37 [Note] Plugin 'FEEDBACK' is disabled. 210109 14:40:37 [ERROR] Unknown/unsupported storage engine: InnoDB 210109 14:40:37 [ERROR] Aborting
可以在报错信息中看到InnoDB相关的错误:checksum mismatch in data file ./ibdata1
原因即为 ibdata1 文件的校验和不匹配
2. 查找以上报错信息相关资料,需要删除此前产生的日志文件
将 /var/lib/mysql/ 目录下的 ibdata1,ib_logfile0,ib_logfile1 几个文件修改文件名后再次尝试启动mariadb成功,服务正常启动后,自动产生了新的文件。