How to fix ERROR 1026: Error writing file in MySQL

MySQLINTERMEDIATEHIGHUpdated Dec 22, 2025ยท 168 views

ERROR 1026 (ER_ERROR_ON_WRITE) occurs when MySQL cannot write to temporary, log, or data files. This is typically caused by insufficient disk space, missing file permissions, or a read-only filesystem. Fixing the underlying filesystem issue resolves the error.

Quick fix

Fixes 1026

df -h
  1. Check available disk space immediately
  2. Verify MySQL data directory ownership and permissions
  3. Check for read-only filesystem
  4. Verify MySQL temp directory is accessible
mysql โ€” error
df -h
ERROR 1026: Error writing file

What this error means

MySQL Error 1026 is a critical file system error that occurs when the MySQL server attempts to write data to a file and the operating system blocks the operation. The error message format includes the filename and an errno value that indicates the specific OS-level problem. Common errno values include 28 (disk full), 13 (permission denied), 2 (file not found), and 30 (read-only filesystem). This error can occur when writing binary logs, temporary query results, table data, or other critical files. If the MySQL master cannot write binary logs, replica servers will lag or stop replicating entirely until the issue is resolved.

Typical symptoms

  • Queries suddenly start failing with "ERROR 1026"
  • Database writes stop working while reads may still succeed
  • Binary log writing fails, preventing replication
  • INSERT, UPDATE, and DELETE operations fail across all tables
  • Temporary file creation fails during large queries or sorts
  • Application connection timeouts when attempting data modifications

Common causes

  1. Disk is full or nearly full (errno 28) - no space for temporary files or log entries
  2. MySQL data directory lacks write permissions for the mysql system user
  3. Filesystem was remounted read-only due to crash or kernel error
  4. Binary log directory missing or inaccessible (errno 2)
  5. File size limits exceeded (ulimit restrictions, FAT32 4GB limit on Windows)
  6. RAID, SAN, or cloud storage I/O errors preventing writes
  7. Container quota or Docker volume size limits reached

How to fix "ERROR 1026: Error writing file"

1Check available disk space immediately

Run the disk usage command to identify space issues:

bash
df -h

Look for the mount point containing your MySQL data directory (typically /var/lib/mysql or /data). If "Use%" shows 100% or very close (95%+), disk space is the problem. You must free up disk space or expand the volume before continuing.

To free space:
- Delete old binary logs: mysql -u root -p -e "PURGE BINARY LOGS BEFORE DATE_SUB(NOW(), INTERVAL 7 DAY);"
- Remove old temporary files: rm -f /tmp/mysql*
- Check for large tables that can be archived or truncated

2Verify MySQL data directory ownership and permissions

Check that the mysql system user owns the data directory:

bash
ls -la /var/lib/mysql | head -5

The output should show "mysql mysql" as owner/group. If not, fix permissions:

bash
sudo chown -R mysql:mysql /var/lib/mysql
sudo chmod -R 750 /var/lib/mysql

On Windows or custom paths, ensure the MySQL service account (usually "MySQL80" or similar) has full control over the data directory through file properties.

3Check for read-only filesystem

List mounted filesystems to identify read-only mounts:

bash
mount | grep -E "ro|rw"

If the MySQL data directory is mounted with "ro" (read-only), remount it as read-write:

bash
sudo mount -o remount,rw /var/lib/mysql

Or remount the entire filesystem:

bash
sudo mount -o remount,rw /

A read-only filesystem often indicates a hardware issue, kernel panic, or filesystem corruption. Check system logs after remounting:

bash
sudo dmesg | tail -20
4Verify MySQL temp directory is accessible

Find your MySQL temp directory:

bash
mysql -u root -p -e "SHOW VARIABLES LIKE 'tmpdir';"

Check that the tmpdir path exists and is writable by the mysql user:

bash
sudo ls -la /tmp/mysql
sudo chmod 1777 /tmp

If using a custom tmpdir, ensure it has sufficient free space and proper ownership. For containerized MySQL, verify your Docker volume or container tmpfs has adequate space.

5Review MySQL error log for the specific errno

Check the MySQL error log for detailed error information:

bash
sudo tail -100 /var/log/mysql/error.log | grep -A 2 "1026"

The error message format is: "ERROR 1026: Error writing file 'filename' (errno: XX - description)"

Common errno values:
- errno 28: No space left on device (disk full)
- errno 13: Permission denied
- errno 2: No such file or directory
- errno 30: Read-only file system

Address the specific errno according to the cause identified above.

6Restart MySQL after fixes are applied

After fixing filesystem issues, restart the MySQL service:

bash
sudo systemctl restart mysql

Or on older systems:

bash
sudo /etc/init.d/mysql restart

Monitor the error log during startup:

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

If replication is enabled, wait for the replica to catch up to the master before resuming application traffic:

bash
mysql -u root -p -e "SHOW SLAVE STATUS\G" | grep "Seconds_Behind_Master"

Advanced notes

For replicated environments: If this error occurs on the master, all replicas will stop replicating and lag indefinitely until the master can write binary logs again. Prioritize fixing this on masters. On replicas, the error usually indicates a problem with the relay log directory or applier temp files.

Container-specific issues: Docker containers and Kubernetes pods often have limited tmpfs space (/tmp). If MySQL creates large temporary tables, they may fail with errno 28. Increase container memory limits or configure MySQL to use a persistent volume for tmpdir.

Cloud storage considerations: When using block storage (EBS, GCP Persistent Disk, Azure Managed Disks), I/O throttling or network disconnection can manifest as error 1026. Check cloud provider metrics and increase IOPS limits if needed.

Windows-specific note: On Windows, FAT32 volumes cannot exceed 4GB per file. If using FAT32 storage for MySQL, upgrade to NTFS. Also check User Account Control (UAC) if the MySQL service lacks admin privileges.

Binary log issues: If the error specifically mentions 'binlog', ensure the binlog directory exists and is writable. Binlog corruption may require rebuilding replication from a fresh backup.

Frequently asked questions

What does "1026" mean?
MySQL Error 1026 is a critical file system error that occurs when the MySQL server attempts to write data to a file and the operating system blocks the operation. The error message format includes the filename and an errno value that indicates the specific OS-level problem. Common errno values include 28 (disk full), 13 (permission denied), 2 (file not found), and 30 (read-only filesystem).
How do I fix "1026"?
ERROR 1026 (ER_ERROR_ON_WRITE) occurs when MySQL cannot write to temporary, log, or data files. This is typically caused by insufficient disk space, missing file permissions, or a read-only filesystem. Fixing the underlying filesystem issue resolves the error.
What causes "1026"?
Disk is full or nearly full (errno 28) - no space for temporary files or log entries MySQL data directory lacks write permissions for the mysql system user Filesystem was remounted read-only due to crash or kernel error
Is the "1026" 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