MySQL版本:5.7

查看mysql启动日志:

2021-09-26T09:00:39.404326Z 1 [ERROR] [MY-012179] [InnoDB] Could not find any file associated with the tablespace ID: 380
2021-09-26T09:00:39.404490Z 1 [ERROR] [MY-012964] [InnoDB] Use --innodb-directories to find the tablespace files. If that fails then use --innodb-force-recovery=1 to ignore this and to permanently lose all changes to the missing tablespace(s)
2021-09-26T09:00:39.504870Z 1 [ERROR] [MY-012930] [InnoDB] Plugin initialization aborted with error Generic error.
2021-09-26T09:00:39.901801Z 1 [ERROR] [MY-010334] [Server] Failed to initialize DD Storage Engine
2021-09-26T09:00:39.902224Z 0 [ERROR] [MY-010020] [Server] Data Dictionary initialization failed.
2021-09-26T09:00:39.902663Z 0 [ERROR] [MY-010119] [Server] Aborting
2021-09-26T09:00:39.903253Z 0 [System] [MY-010910] [Server] /usr/sbin/mysqld: Shutdown complete (mysqld 8.0.20)  MySQL Community Server - GPL.
2021-09-26 09:02:11+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 8.0.20-1debian10 started.
2021-09-26 09:02:11+00:00 [Note] [Entrypoint]: Switching to dedicated user 'mysql'
2021-09-26 09:02:11+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 8.0.20-1debian10 started.
2021-09-26T09:02:12.086714Z 0 [Warning] [MY-011070] [Server] 'Disabling symbolic links using --skip-symbolic-links (or equivalent) is the default. Consider not using this option as it' is deprecated and will be removed in a future release.

故障:

数据库文件d_smp被手动删除,导致mysql无法启动。

解决:

1、查阅官方文档,在mysql配置文件中/etc/my.cnf添加配置,就可以成功启动。

[mysqld]
innodb_force_recovery = 1

        innodb_force_recovery参数解释:崩溃恢复模式,通常只有在严重故障排除情况下才会改变。可以的值是从0到6。

        只有在紧急情况下才将这个变量设置为大于0的值,这样你才能启动InnoDB并转储你的表。作为一种安全措施,当innodb_force_recovery大于0时,InnoDB可以防止插入、更新或删除操作。
        在5.6.15,innodb_force_recovery设置为4或更大,将InnoDB设置为只读模式。由于relay_log_info_repository=TABLE和master_info_repository=TABLE在InnoDB表中存储信息,这些限制可能导致复制管理命令失败并出现错误。

启动后,发现无法删除数据库。

ERROR 3679 (HY000): Schema directory './d_smp/' does not exist

如果,确实发现该数据已不存在,而且确实要删除该数据库。下面提供一种强制删除的方法。

#删除一个已经确定存在的数据库:
mysql> drop database d_smp;
Query OK, 0 rows affected (0.00 sec)




#删除一个不确定存在的数据库:
#发生错误,不能删除'd_smp'数据库,该数据库不存在。
mysql> drop database d_smp;
ERROR 1008 (HY000): Can't drop database 'd_smp'; database doesn't exist


#产生一个警告说明此数据库不存在
mysql> drop database if exists d_smp;
Query OK, 0 rows affected, 1 warning (0.00 sec)

#创建一个数据库
mysql> create database d_smp;  
Query OK, 1 row affected (0.00 sec)
#if exists 判断数据库是否存在,不存在也不产生错误
mysql> drop database if exists d_smp;  
Query OK, 0 rows affected (0.00 sec)

Logo

为开发者提供学习成长、分享交流、生态实践、资源工具等服务,帮助开发者快速成长。

更多推荐