<p>Error 1556 occurs when a statement tries to lock the special log tables (general_log or slow_log), which MySQL forbids.</p>
<p>MySQL Error 1556: ER_CANT_LOCK_LOG_TABLE means the server rejected an explicit LOCK TABLES or similar command on general_log or slow_log. Remove or skip the lock operation, or switch logging to FILE, to resolve the issue.</p>
You can't use locks with log tables.
The error 'You can't use locks with log tables' occurs when a statement attempts to explicitly lock a log table with LOCK TABLES or performs an implicit lock through ALTER TABLE, CREATE INDEX, or certain DDL operations. MySQL treats general_log and slow_log as protected log tables and disallows explicit locking because that would interrupt the server's ability to write new log rows.
Maintenance scripts, backup utilities, or ad-hoc sessions that issue blanket LOCK TABLES across all tables will trigger the error when the command reaches one of the log tables. The server aborts the lock request, returning SQLSTATE HY000 and error code 1556.
LOCK TABLES general_log WRITE or LOCK TABLES slow_log WRITE directly causes the error because MySQL blocks write locks on log tables. Wildcard statements such as LOCK TABLES * WRITE or automation loops that lock every table in the current schema also fail once they encounter a log table.
mysqldump with the --lock-tables option produces the same failure if the dump includes the mysql system database where log tables reside. Older ALTER TABLE commands on log tables can also invoke an implicit lock and generate error 1556.
Remove log tables from explicit LOCK TABLES lists. Optionally switch logging output to FILE during the operation: SET GLOBAL general_log = 'OFF'; SET GLOBAL log_output = 'FILE'; perform maintenance; SET GLOBAL log_output = 'TABLE'; SET GLOBAL general_log = 'ON'.
When using mysqldump, add --skip-lock-tables or --no-tablespaces, or restrict the dump to databases that do not include log tables. Application code should detect table names general_log and slow_log and bypass locking logic.
Backup scripts that iterate through INFORMATION_SCHEMA.TABLES must filter out ENGINE='CSV' or TABLE_NAME IN ('general_log','slow_log'). Doing so allows the rest of the lock sequence to proceed.
Migration frameworks that default to LOCK TABLES * WRITE should switch to FLUSH TABLES WITH READ LOCK, which does not lock the individual log tables yet still offers a global read lock for snapshot creation.
Keep logging output to FILE when frequent global locks are required, especially on busy servers. Maintain separate maintenance users that lock only transactional tables explicitly listed, never using wildcards.
Monitor the MySQL error log for code 1556 and update scripts promptly. Document log table restrictions in developer guidelines to prevent future errors.
Error 1557 ER_CANT_ROTATE_LOGFILE appears when MySQL cannot rotate log files; check file system permissions on log directories. Error 1558 ER_BAD_LOG_STATEMENT signals invalid log-related statements; verify syntax and parameter names. Unlike 1556, these errors relate to file handling and syntax rather than table locking.
Running LOCK TABLES general_log WRITE fails because MySQL forbids write locks on log tables.
Scripts that lock every table in a schema inevitably hit log tables and trigger error 1556.
Dumping the mysql system database with --lock-tables attempts to lock log tables, producing the error.
Occurs when the server cannot rotate a log file. Check directory permissions.
Raised for malformed log-related SQL. Review SET GLOBAL or SHOW statements for typos.
Indicates a lock wait timeout, unrelated to log tables but still about locking.
No. MySQL intentionally prevents explicit locks on log tables to keep logging uninterrupted.
No. That command applies a global read lock without touching individual log tables.
Yes. When log_output is FILE, log tables are not actively used, enabling scripts that lock all non-log tables.
Galaxy highlights system tables like general_log in the schema viewer, warning users before they add them to LOCK TABLES statements, reducing the chance of error 1556.