How to fix ERROR 1024: Error reading file in MySQL

MySQLINTERMEDIATEHIGHUpdated Dec 22, 2025ยท 175 views

MySQL ERROR 1024 (ER_ERROR_ON_READ) occurs when MySQL cannot read a database file due to permissions, corruption, or disk issues. Fixes involve checking permissions, disk space, file integrity, and restarting the MySQL server.

Quick fix

Fixes ERROR 1024: Error reading file

df -h
  1. Check available disk space
  2. Review MySQL error logs for details
  3. Check and fix file permissions
  4. Check and repair table integrity
mysql โ€” error
df -h
ERROR 1024: Error reading file

What this error means

ERROR 1024 is a general file read error that indicates MySQL encountered a problem while attempting to access a database file. The error message includes the filename and system error number (errno) for additional context. This error can originate from the MySQL server daemon when it tries to read table data files, temporary files, or configuration files. The underlying cause could be file system issues, access problems, or hardware failures.

Typical symptoms

  • MySQL queries fail with "ERROR 1024: Error reading file" message
  • Specific tables or databases become inaccessible
  • Database operations timeout or hang unexpectedly
  • Queries that previously worked suddenly fail
  • Error logs show repeated "Error reading file" messages

Common causes

  1. Insufficient file permissions - MySQL server user cannot read the file
  2. File corruption from unexpected server shutdown or hardware failure
  3. Insufficient disk space preventing file access operations
  4. Damaged or failing storage device with bad sectors
  5. Incorrect file path in SELECT INTO OUTFILE or LOAD DATA INFILE statements
  6. Too many open files reaching the system limit

How to fix "ERROR 1024: Error reading file"

1Check available disk space

Verify that your server has sufficient disk space. Use the df command to check:

bash
df -h

If disk usage is above 90%, you need to free up space by deleting unnecessary files or expanding your storage capacity. MySQL cannot properly read or write files when the disk is full.

2Review MySQL error logs for details

Examine the MySQL error logs to get the specific filename and errno that caused the error. The logs are typically located at:

bash
tail -f /var/log/mysql/error.log

Or on macOS:

bash
tail -f /usr/local/var/mysql/error.log

Look for the exact file path and system error code, which will help identify the root cause.

3Check and fix file permissions

Ensure the MySQL server user (usually "mysql") has read permissions for the affected files. First, identify which file is causing the issue from your logs.

Check current permissions:

bash
ls -la /var/lib/mysql/yourdatabase/yourfile

Fix permissions if needed:

bash
chown mysql:mysql /var/lib/mysql/yourdatabase/yourfile
chmod 660 /var/lib/mysql/yourdatabase/yourfile

If the entire database directory has permission issues:

bash
chown -R mysql:mysql /var/lib/mysql/yourdatabase/
chmod -R 750 /var/lib/mysql/yourdatabase/
4Check and repair table integrity

For MyISAM tables, use CHECK TABLE to identify corruption:

sql
CHECK TABLE yourtable;

If issues are found, repair the table:

sql
REPAIR TABLE yourtable;

For InnoDB tables, use mysqlcheck with auto-repair:

bash
mysqlcheck -u root -p --auto-repair --check --optimize yourdatabase

This will check all tables in the database and automatically repair any issues found.

5Verify file paths in queries

If the error occurs with LOAD DATA INFILE or SELECT INTO OUTFILE statements, verify the file paths are correct:

sql
LOAD DATA LOCAL INFILE '/absolute/path/to/file.csv'
INTO TABLE yourtable
FIELDS TERMINATED BY ','
LINES TERMINATED BY '\n';

Ensure:
- The path is absolute (starts with /), not relative
- The file exists and is readable by MySQL
- The file is on a partition MySQL can access
- Use LOCAL keyword if the file is on the client machine

6Increase open files limit if needed

If many queries are failing, the system may have reached the open files limit (often 1024). Check the current limit:

bash
ulimit -n

Increase the limit by editing /etc/security/limits.conf:

bash
echo "mysql soft nofile 65535" >> /etc/security/limits.conf
echo "mysql hard nofile 65535" >> /etc/security/limits.conf

Then edit the MySQL configuration file (/etc/mysql/my.cnf or /etc/my.cnf):

ini
[mysqld]
open_files_limit = 65535

Restart MySQL for changes to take effect.

7Restart MySQL server

After making configuration or permission changes, restart MySQL:

bash
sudo systemctl restart mysql

On macOS:

bash
mysql.server restart

Verify it's running:

bash
mysql -u root -p -e "SELECT 1;"

After restart, attempt the operation that was failing to see if the error is resolved.

8Check for hardware issues

If the error persists after all above steps, suspect hardware failure. Run disk diagnostics:

bash
sudo smartctl -a /dev/sda

For ext4 filesystems, run:

bash
sudo e2fsck -n /dev/sda1

If the diagnostics show bad sectors or drive errors, back up your data immediately and plan to replace the storage device. Hardware failure is a serious issue that may prevent reliable database operation.

Advanced notes

ERROR 1024 can have different root causes depending on context. When it occurs during bulk LOAD DATA operations, it's usually a permissions or file path issue. During normal queries on corrupted tables, it's typically corruption or hardware failure. The errno value in the error message is critical - it's the system error code that can give more specific information (e.g., EACCES for permission denied, EIO for input/output error). On very high-traffic servers, reaching the open_files_limit is common; consider setting it to at least 65535. Some hosting providers may restrict file path access for security; always use absolute paths and verify the file is in an accessible location.

Frequently asked questions

What does "ERROR 1024: Error reading file" mean?
ERROR 1024 is a general file read error that indicates MySQL encountered a problem while attempting to access a database file. The error message includes the filename and system error number (errno) for additional context. This error can originate from the MySQL server daemon when it tries to read table data files, temporary files, or configuration files.
How do I fix "ERROR 1024: Error reading file"?
MySQL ERROR 1024 (ER_ERROR_ON_READ) occurs when MySQL cannot read a database file due to permissions, corruption, or disk issues. Fixes involve checking permissions, disk space, file integrity, and restarting the MySQL server.
What causes "ERROR 1024: Error reading file"?
Insufficient file permissions - MySQL server user cannot read the file File corruption from unexpected server shutdown or hardware failure Insufficient disk space preventing file access operations
Is the "ERROR 1024: Error reading file" error serious?
Yes. This is a high-severity error that usually blocks work until it is fixed, but the steps above resolve it.

Official resources & further reading