Error
Error Code: 1033

MySQL Error 1033: Malformed Table Definition

📦 MySQL
📋

Description

Error 1033, 'Incorrect information in file: %s', signifies that MySQL encountered an issue reading a table's definition file (typically a .frm file). This usually occurs when the file is corrupted, incomplete, ironically named, or contains invalid metadata, preventing the database from accessing the table's structure.
💬

Error Message

Incorrect information in file: '%s'
🔍

Known Causes

4 known causes
⚠️
Corrupted Table Definition File
The .frm file, which defines the table's structure, has become damaged or unreadable due to sudden power loss, hardware failure, or software bugs.
⚠️
Incomplete File Transfer or Copy
A table's .frm file was not fully copied or transferred, resulting in a truncated or partially written file that MySQL cannot parse correctly.
⚠️
Underlying Filesystem Corruption
Problems with the disk or filesystem itself can lead to data corruption within database files, making them appear malformed to MySQL.
⚠️
Manual Database File Manipulation
The .frm file was manually edited, moved, or deleted outside of MySQL's management, leading to inconsistencies and unreadable data.
🛠️

Solutions

4 solutions available

1. Rebuild the Corrupted Table medium

This solution involves recreating the table from scratch, which is effective if the table definition file is indeed malformed.

1
Identify the table causing the error. The error message '%s' usually contains the filename of the corrupted table.
2
Back up the data from the corrupted table. If you can still select data, do so. If not, you might need to attempt data recovery from the `.ibd` file (advanced).
SELECT * INTO OUTFILE '/path/to/backup/table_name.sql' FROM your_database.your_table;
3
Drop the corrupted table.
DROP TABLE your_database.your_table;
4
Recreate the table using its original `CREATE TABLE` statement. If you don't have it, you can try to infer it from the data backup or by using `SHOW CREATE TABLE` on a healthy replica if available. Alternatively, you can use `mysqldump` to get the schema.
SHOW CREATE TABLE your_database.your_table;
-- Then use the output to reconstruct the table definition.
5
Import the data back into the newly created table.
LOAD DATA INFILE '/path/to/backup/table_name.sql' INTO TABLE your_database.your_table;

2. Check and Repair Table Files (MyISAM) easy

For MyISAM tables, MySQL provides built-in repair utilities.

1
Identify the database and table name from the error message.
2
Connect to your MySQL server using the command-line client.
mysql -u your_user -p
3
Execute the `REPAIR TABLE` command. Replace `your_database` and `your_table` with your actual database and table names.
REPAIR TABLE your_database.your_table;
4
If the repair is successful, try accessing the table again.

3. Restart MySQL Server easy

A simple server restart can sometimes resolve transient file access issues or clear internal caches that might be causing this error.

1
Gracefully shut down the MySQL server.
sudo systemctl stop mysql  # For systemd-based systems (e.g., Ubuntu 15.04+, CentOS 7+)
# or
sudo service mysql stop  # For older SysVinit-based systems
2
Wait for the server to fully stop. You can check the process list to confirm.
ps aux | grep mysql
3
Start the MySQL server.
sudo systemctl start mysql  # For systemd-based systems
# or
sudo service mysql start  # For older SysVinit-based systems
4
Attempt to access the affected table again.

4. Inspect and Restore Table Files (InnoDB) advanced

For InnoDB tables, the `.ibd` file is crucial. Corruption here often requires more advanced recovery.

1
Locate the data directory of your MySQL installation. This is usually specified by the `datadir` variable in your `my.cnf` or `my.ini` configuration file.
2
Find the `.frm` (table definition) and `.ibd` (table data and indexes) files for the problematic table within the database's subdirectory.
3
If you have a recent backup of these files, stop the MySQL server, replace the corrupted files with the backup, and restart the server.
4
If no backup is available, consider using MySQL's built-in recovery features or third-party InnoDB recovery tools. This is a complex process that may involve exporting data from the corrupted `.ibd` file if possible.
5
Ensure that the MySQL server process has the necessary read/write permissions to the data directory and its contents.
🔗

Related Errors

5 related errors