How to fix ERROR 1182: Got error during FLUSH_LOGS in MySQL

MySQLINTERMEDIATEHIGHUpdated Dec 23, 2025ยท 205 views

ERROR 1182 occurs when MySQL cannot rotate or flush its binary, relay, or general query logs due to disk space issues, file permission problems, or I/O errors. Fix by freeing disk space, correcting log directory permissions, or resolving filesystem errors, then retry the FLUSH LOGS operation.

Quick fix

Fixes 1182

df -h /var/log
df -h /var/lib/mysql
  1. Check available disk space on the log partition
  2. Free up disk space if needed
  3. Verify and fix log directory permissions
  4. Check SELinux or AppArmor restrictions
mysql โ€” error
df -h /var/log
df -h /var/lib/mysql
ERROR 1182: Got error during FLUSH_LOGS

What this error means

ERROR 1182 (HY000: ER_ERROR_DURING_FLUSH_LOGS) is a runtime error that occurs when the MySQL server attempts to flush or rotate its logs (binary logs, relay logs, general query log, or slow query log) but encounters an underlying operating system or filesystem error. This prevents the server from creating new log files or closing and reopening existing ones. The error indicates a system-level problem rather than a SQL syntax issue, and it often leaves logging in an inconsistent state if the operation fails mid-process.

Typical symptoms

  • FLUSH LOGS command fails with ERROR 1182
  • Binary log rotation fails during log recovery or replication
  • General query log or slow query log cannot be flushed
  • Server runs with logging disabled after a flush failure, despite configuration showing logging enabled
  • Error message includes specific OS error code (errno 13, 28, etc.) in MySQL error log
  • Log rotation via mysqladmin or logrotate scripts fails
  • Replication fails because binary logs cannot be properly flushed

Common causes

  1. Insufficient disk space on the partition where log files are stored (errno 28: ENOSPC)
  2. Log directory or files lack write permissions for the MySQL process user (errno 13: EACCES)
  3. Log file location is not writable (e.g., /var/log owned by root, not mysql)
  4. SELinux or AppArmor security policies block MySQL write access to log directories
  5. Log file path contains a non-existent or inaccessible directory
  6. Corrupted or inaccessible binary log index file (.index)
  7. Filesystem is mounted read-only or has I/O errors
  8. Process running under a restricted account without proper permissions

How to fix "ERROR 1182: Got error during FLUSH_LOGS"

1Check available disk space on the log partition

Determine how much disk space is available where the log files are stored.

For Linux/Unix:

bash
df -h /var/log
df -h /var/lib/mysql

Check current log file sizes:

bash
du -sh /var/log/mysql/
du -sh /var/lib/mysql/*.log*

If available space is critically low (< 5% free), this is likely the cause. Proceed to Step 2 to free disk space.

2Free up disk space if needed

If disk space is low, remove old log files and binaries:

1. Purge old binary logs (if binary logging is enabled):

sql
SHOW BINARY LOGS;
PURGE BINARY LOGS BEFORE DATE_SUB(NOW(), INTERVAL 7 DAY);

2. Remove old MySQL general or slow query logs (if they're not in rotation):

bash
sudo rm -f /var/log/mysql/mysql.log*
sudo rm -f /var/log/mysql/mysql-slow.log*

3. Clean up system logs if they share the partition:

bash
sudo find /var/log -name "*.gz" -mtime +30 -delete
sudo journalctl --vacuum=30d

4. Expand storage if you need more capacity long-term:
- Add a new disk or extend the existing partition
- Configure MySQL to use a separate log directory on another volume

3Verify and fix log directory permissions

Check that the MySQL process has write access to log directories.

For Linux/Unix, check current permissions:

bash
ls -ld /var/log/mysql
ls -l /var/log/mysql/

The MySQL user (typically 'mysql') must own the directory or have write permissions:

bash
sudo chown -R mysql:mysql /var/log/mysql
sudo chmod 750 /var/log/mysql
sudo chmod 640 /var/log/mysql/*.log

On systems where the error log is in /var/log directly:

bash
sudo touch /var/log/mysqld.log
sudo chown mysql:mysql /var/log/mysqld.log
sudo chmod 640 /var/log/mysqld.log

For Docker containers, ensure the entrypoint creates log files with proper ownership before MySQL starts.

4Check SELinux or AppArmor restrictions

If using SELinux, verify the context is correct for log directories:

bash
ls -Z /var/log/mysql/
# Should show a context like: mysql_log_t or var_log_t

If the context is wrong, restore it:

bash
sudo restorecon -R /var/log/mysql

If using AppArmor, check the MySQL profile:

bash
sudo aa-status | grep mysql

Check the AppArmor denial log:

bash
sudo grep DENIED /var/log/syslog | grep mysql | tail -10

If denials exist, the profile may need to be updated to allow the log path.

5Check MySQL error log for specific OS error details

Review the MySQL error log to see the exact operating system error code:

For Linux/Unix (default locations):

bash
tail -30 /var/log/mysql/error.log
# or
tail -30 /var/log/mysqld.log

For Windows:

cmd
type "C:\ProgramData\MySQL\MySQL Server 8.0\Data\hostname.err"

Look for lines like:

bash
ERROR 1182: Got error during FLUSH_LOGS
... error 13: Permission denied
... error 28: No space left on device

The error code (13, 28, etc.) tells you the root cause.

6Retry the FLUSH LOGS operation

Once you've fixed the underlying issue (disk space, permissions, or SELinux), attempt the flush again:

sql
FLUSH LOGS;

Or using the command line:

bash
mysqladmin flush-logs

If it still fails, check the error log again for a different OS error code. You may need to restart MySQL for some permission changes to take effect:

bash
sudo systemctl restart mysql

Verify logging is active:

sql
SHOW VARIABLES LIKE '%log%';

Advanced notes

Binary Log Recovery: If binary logging is critical and flush fails repeatedly, consider temporarily disabling it until root cause is fixed:

ini
[mysqld]
skip-log-bin  # Temporarily disable to test

Log Rotation with Logrotate: On Linux, logrotate can send SIGHUP to trigger log reopening without explicit FLUSH LOGS:

bash
/var/log/mysql/mysql-slow.log {
  daily
  rotate 7
  compress
  delaycompress
  notifempty
  create 640 mysql mysql
  sharedscripts
  postrotate
    /usr/bin/mysqladmin flush-logs > /dev/null 2>&1 || true
  endscript
}

Alternative Signal to FLUSH LOGS: If FLUSH LOGS hangs or repeatedly fails, use SIGUSR1 instead, which flushes error, general, and slow query logs without affecting binary logs:

bash
kill -SIGUSR1 $(pgrep mysqld)

Replication Considerations: If this server is a MySQL replica, binary log rotation failures can break replication. Ensure the relay log directory has sufficient space and permissions too. On a primary server, monitor the binary log size to prevent unbounded growth:

ini
[mysqld]
max_binlog_size = 100M  # Rotate after 100MB (default)

Filesystem I/O Errors: If the OS error is something like errno 5 (EIO), the underlying filesystem may be degraded. Run filesystem checks:

bash
sudo fsck -n /dev/sdXY  # Check without repair
sudo fsck /dev/sdXY      # Repair if needed (run offline)

Frequently asked questions

What does "1182" mean?
ERROR 1182 (HY000: ER_ERROR_DURING_FLUSH_LOGS) is a runtime error that occurs when the MySQL server attempts to flush or rotate its logs (binary logs, relay logs, general query log, or slow query log) but encounters an underlying operating system or filesystem error. This prevents the server from creating new log files or closing and reopening existing ones. The error indicates a system-level problem rather than a SQL syntax issue, and it often leaves logging in an inconsistent state if the operation fails mid-process.
How do I fix "1182"?
ERROR 1182 occurs when MySQL cannot rotate or flush its binary, relay, or general query logs due to disk space issues, file permission problems, or I/O errors. Fix by freeing disk space, correcting log directory permissions, or resolving filesystem errors, then retry the FLUSH LOGS operation.
What causes "1182"?
Insufficient disk space on the partition where log files are stored (errno 28: ENOSPC) Log directory or files lack write permissions for the MySQL process user (errno 13: EACCES) Log file location is not writable (e.g., /var/log owned by root, not mysql)
Is the "1182" 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