mysql Can‘t open and lock privilege tables: Table ‘.\mysql\db‘ is marked as crashed .. repair failed

本文详细记录了在遇到XAMPP的MySQL服务因数据表错误而报错的情况下,如何使用MariaDB的aria_chk工具进行修复。通过检查、分析和优化命令,成功修复了损坏的数据库,并最终重启MySQL服务恢复正常运行。

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

今日xampp的mysql报错
Fatal error: Can't open and lock privilege tables: Table '.\mysql\db' is marked as crashed and last (automatic?) repair failed

经过查询 貌似是 数据表发生了错误导致的,可以使用
myisamchk来修复
myisamchk -f -o tablename.MYI
但是我使用的是MariaDB,所以里面没有MYI文件
再次查询
https://mariadb.com/kb/en/aria_chk/
发现需要使用 aria_chk 来修复
入股MYSQL正在运行,首先关闭MYSQL服务
然后
The following commands, run in the MariaDB data directory, check all your tables and repairs only those that have an error:

aria_chk --check --sort_order --force --sort_buffer_size=1G */*.MAI

If you want to optimize all your tables: (The --zerofill is used here to fill up empty space with \0 which can speed up compressed backups).

aria_chk --analyze --sort-index --page_buffer_size=1G --zerofill */*.MAI

In case you have a serious problem and have to use --safe-recover:

aria_chk --safe-recover --zerofill --page_buffer_size=2G */*.MAI

根据以上说明 我运行了以下命令
aria_chk --safe-recover --zerofill --page_buffer_size=2G db.MAI

,然后重启mysql 搞定

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值