Error
Error Code: 1000

MariaDB Error 1000: Table Hash Check Failure

📦 MariaDB
📋

Description

MariaDB Error 1000, symbolized as ER_HASHCHK, indicates that the database encountered an inconsistency during an internal hash check. This error typically signifies data corruption within a table or an index, preventing the database from reliably accessing or verifying its structure. It can occur during routine operations, server startup, or specific maintenance tasks.
💬

Error Message

hashchk
🔍

Known Causes

3 known causes
⚠️
Corrupted Table or Index
Physical corruption of table files or indexes on disk can lead to hash check failures during data access or verification.
⚠️
Underlying Hardware Problems
Faulty disk drives, RAID controllers, or memory issues can introduce errors into data written to disk, resulting in data corruption that triggers this error.
⚠️
Improper Database Shutdown
Abrupt power loss or an ungraceful shutdown of the MariaDB server can leave tables in an inconsistent state, leading to integrity check failures upon restart.
🛠️

Solutions

4 solutions available

1. Check and Repair Tables easy

Use CHECK TABLE and REPAIR TABLE to identify and fix corruption

1
First, identify which tables are corrupted by checking all tables
mysqlcheck -u root -p --check --all-databases
2
For MyISAM tables, run REPAIR TABLE
REPAIR TABLE database_name.table_name;
3
For InnoDB tables, use optimize instead (InnoDB self-heals on restart)
OPTIMIZE TABLE database_name.table_name;

2. Use myisamchk for Offline Repair medium

Repair MyISAM tables when server is stopped

1
Stop the MariaDB server first
sudo systemctl stop mariadb
2
Run myisamchk to check and repair the table
myisamchk -r /var/lib/mysql/database_name/table_name.MYI
3
For severe corruption, use extended recovery
myisamchk -r -q /var/lib/mysql/database_name/table_name.MYI
4
Start the server again
sudo systemctl start mariadb

3. Force InnoDB Recovery advanced

Use innodb_force_recovery for severely corrupted InnoDB tables

1
Stop MariaDB server
sudo systemctl stop mariadb
2
Edit MariaDB configuration to enable force recovery mode
[mysqld]
innodb_force_recovery = 1
3
Start MariaDB and dump all data
sudo systemctl start mariadb
mysqldump -u root -p --all-databases > backup.sql
4
Remove force recovery, reinitialize database, and restore
sudo systemctl stop mariadb
# Remove innodb_force_recovery from config
sudo rm -rf /var/lib/mysql/ib*
sudo systemctl start mariadb
mysql -u root -p < backup.sql

4. Restore from Backup medium

If repair fails, restore from a known good backup

1
Stop the server and locate your backup
sudo systemctl stop mariadb
2
Restore from mysqldump backup
mysql -u root -p database_name < backup.sql
3
Or restore from binary backup (copy data files)
sudo cp -r /path/to/backup/database_name /var/lib/mysql/
sudo chown -R mysql:mysql /var/lib/mysql/database_name
4
Start the server
sudo systemctl start mariadb
🔗

Related Errors

5 related errors