ERROR 1033 occurs when MySQL encounters corrupted or malformed table files (.frm, .MYD, or .MYI). This typically indicates table corruption from hardware failures, unexpected shutdowns, or filesystem issues that prevent MySQL from reading critical table metadata.
MySQL Error 1033 (SQLSTATE: HY000, ER_NOT_FORM_FILE) indicates that MySQL encountered corrupted or incomplete information in a table file. This error most commonly occurs when: - The .frm (table definition) file is corrupted or has an invalid format - The .MYD (data) or .MYI (index) files for MyISAM tables contain corrupted data structures - InnoDB table headers are incomplete or unreadable - The file was partially written due to an unexpected shutdown or power loss This is a critical issue because it prevents MySQL from reading or writing to the affected table, causing application errors and potential data loss if not addressed promptly.
Before attempting any repairs, stop MySQL cleanly to prevent further corruption:
sudo systemctl stop mysql
# OR
sudo systemctl stop mariadb
# OR on older systems
sudo /etc/init.d/mysql stopWait a few seconds to ensure all MySQL processes have terminated.
MySQL requires the temp directory to be writable. Verify and fix permissions:
# Check /tmp permissions (should be 777)
ls -ld /tmp
ls -ld /var/tmp
# Fix permissions if needed
sudo chmod 777 /tmp
sudo chmod 777 /var/tmpAlso check the MySQL configuration to see which temp directory is configured:
grep tmpdir /etc/mysql/my.cnf
# or
grep tmpdir /etc/my.cnfEnsure the tmpdir path in my.cnf points to a valid, writable directory.
Ensure the MySQL data directory has correct ownership and permissions:
# Check current ownership and permissions
ls -ld /var/lib/mysql
# Fix ownership (should be mysql:mysql)
sudo chown -R mysql:mysql /var/lib/mysql
# Fix permissions (typically 755)
sudo chmod -R 755 /var/lib/mysqlThe mysql user must have read and write access to all table files in the data directory.
Start MySQL and use the mysqlcheck utility to check and repair all tables:
# Start MySQL
sudo systemctl start mysql
# Check and repair all tables (auto-repair mode)
mysqlcheck -u root -p --auto-repair --check --all-databases
# For a specific database only
mysqlcheck -u root -p --auto-repair --check database_name
# For a specific table
mysqlcheck -u root -p --auto-repair --check database_name table_nameThe --auto-repair flag will automatically repair any corrupted tables it finds. You'll be prompted for the MySQL root password.
If mysqlcheck doesn't fully resolve the issue, try manual repair from within MySQL:
-- Connect to MySQL
mysql -u root -p
-- Attempt quick repair
REPAIR TABLE table_name QUICK;
-- If quick repair fails, try medium repair (rebuilds index)
REPAIR TABLE table_name MEDIUM;
-- Extended repair (rebuilds index from scratch)
REPAIR TABLE table_name EXTENDED;
-- Check table status after repair
CHECK TABLE table_name;Start with QUICK, which is fastest and safest. Only use EXTENDED if MEDIUM fails.
If the table uses InnoDB storage engine and repair fails, check configuration and potentially use force recovery:
1. Verify InnoDB is enabled (check that skip-innodb is commented out in my.cnf)
2. Check ibdata1 file size matches configuration:
# Check actual file size
ls -lh /var/lib/mysql/ibdata1
# View configuration
grep innodb_data_file_path /etc/mysql/my.cnf3. If the size doesn't match, either:
- Update the configuration to match the actual file size, OR
- Delete the InnoDB data files and let MySQL recreate them (data loss!)
4. If needed, use InnoDB force recovery (last resort):
# Edit my.cnf
sudo nano /etc/mysql/my.cnf
# Add this line to the [mysqld] section
innodb_force_recovery = 3
# Restart MySQL
sudo systemctl restart mysql
# Once you can start MySQL, dump the database
mysqldump -u root -p --all-databases > backup.sql
# Then stop MySQL, remove the InnoDB configuration line, and restartWARNING: Force recovery levels 4-6 can permanently corrupt InnoDB data. Use incrementally: start at 1, increase only if MySQL won't start.
If repair commands fail to resolve the issue, restore from your most recent backup:
# Check if you have a recent mysqldump backup
ls -lt /path/to/backups/ | head -5
# Restore from backup
mysql -u root -p < backup.sql
# Or restore a specific database
mysql -u root -p database_name < database_backup.sqlIf no backup exists, consider professional data recovery services as a last resort. Ensure all table structures and data are fully restored and verified.
InnoDB vs MyISAM Storage Engine
Error 1033 is more common with MyISAM tables, which don't have crash-safe guarantees. InnoDB is more resilient due to its redo logs and crash recovery mechanisms. Consider converting existing MyISAM tables to InnoDB:
ALTER TABLE table_name ENGINE=InnoDB;Prevent Future Corruption
1. Enable myisam_recover_options in my.cnf for automatic repair on startup:
[mysqld]
myisam_recover_options=BACKUP,FORCE2. Use InnoDB for all new transactional tables
3. Enable regular automated backups (daily or more frequently for critical data)
4. Monitor disk health and filesystem errors (SMART tools, filesystem checks)
5. Schedule regular CHECK TABLE maintenance during low-traffic windows
6. Use UPS to prevent unexpected power loss
Troubleshooting Specific Scenarios
- Error after MySQL upgrade: Verify all tables with CHECK TABLE, backup immediately, then consider dumping and reloading the database
- Multiple tables corrupted: Indicates filesystem or hardware issues; run fsck and check disk health (badblocks, SMART status)
- mysqldump fails but MySQL runs: Use --skip-lock-tables and --max_allowed_packet options, or dump individual tables
- Error during replication: Repair on the replica first without affecting the primary; if primary is affected, failover to replica
EE_WRITE (3): Error writing file
How to fix "EE_WRITE (3): Error writing file" in MySQL
CR_PARAMS_NOT_BOUND (2031): No data supplied for parameters
How to fix "CR_PARAMS_NOT_BOUND (2031): No data supplied for parameters" in MySQL
CR_DNS_SRV_LOOKUP_FAILED (2070): DNS SRV lookup failed
How to fix "CR_DNS_SRV_LOOKUP_FAILED (2070): DNS SRV lookup failed" in MySQL
ERROR 1146: Table 'database.table' doesn't exist
How to fix "ERROR 1146: Table doesn't exist" in MySQL
ERROR 1040: Too many connections
How to fix "ERROR 1040: Too many connections" in MySQL