今日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 搞定