Common SQL Errors

MySQL Error 1098: ER_NO_UNIQUE_LOGFILE – Fixing “Can't generate a unique log-filename”

Galaxy Team
August 5, 2025

MySQL cannot create a new binary or relay log file because every candidate name from 1-999 already exists or is unwritable.

Sign up for the latest in common SQL errors from the Galaxy Team!
Welcome to the Galaxy, Guardian!
You'll be receiving a confirmation email

Follow us on twitter :)
Oops! Something went wrong while submitting the form.

What is MySQL error 1098: ER_NO_UNIQUE_LOGFILE?

MySQL Error 1098: ER_NO_UNIQUE_LOGFILE appears when the server fails to create a new binary or relay log because every candidate file name already exists or cannot be written. Remove or rename stale log files, free disk space, or set a unique --log-bin or --relay-log basename to resolve it.

Error Highlights

Typical Error Message

Can't generate a unique log-filename %s.(1-999)

Error Type

Replication Error

Language

MySQL

Symbol

ER_NO_UNIQUE_LOGFILE

Error Code

1098

SQL State

Explanation

Table of Contents

What is MySQL Error 1098: ER_NO_UNIQUE_LOGFILE?

Error 1098 with condition name ER_NO_UNIQUE_LOGFILE is raised when MySQL tries to create a binary log (or relay log) file but cannot find a unique filename in the 1-999 suffix range.

The server aborts the operation and replication may stop.

The message usually appears at server startup, during replication initialisation, or after FLUSH LOGS when the configured log basename already has numbered files occupying every suffix.

Why is fixing this error important?

Replication breaks if MySQL cannot rotate or initialise its logs. Backups that rely on binary logging also fail. Ignoring the error risks data loss, delayed replicas, and increased recovery time.

What Causes This Error?

Filename collisions are the primary cause.

MySQL appends .000001-.000999 to the --log-bin or --relay-log basename. If every candidate file exists, the server stops.

Insufficient permissions, full disk, or read-only filesystems prevent MySQL from deleting or creating logs, triggering the same error.

Misconfigured Docker volumes, stale relay logs after server re-clones, or incorrect custom paths also lead to collisions.

How to Fix MySQL Error 1098: ER_NO_UNIQUE_LOGFILE

First, identify unused or orphaned log files. Rename or purge them so at least one suffix is free.

Ensure the MySQL operating system user owns the directory.

Next, restart the server or issue FLUSH LOGS. MySQL will create the next available file once a gap exists.

If cleanup is impossible, change the basename with --log-bin=mysqllog or --relay-log=relay to force a new numbering sequence.

Common Scenarios and Solutions

On a replica that was copied via rsync, leftover master relay logs often collide.

Remove relay-log.* before starting mysqld.

Inside a container where /var/lib/mysql is persistent but configuration resets, each fresh container instance can reuse the same basename. Mount a unique subfolder or adjust the basename per replica.

Best Practices to Avoid This Error

Automate PURGE BINARY LOGS TO or PURGE BINARY LOGS BEFORE to keep file counts low. Monitor the number of files with SHOW BINARY LOGS.

Always set unique basenames that incorporate the hostname or instance id: --log-bin=binlog_$HOSTNAME.

Galaxy users can store these settings in versioned scripts for team visibility.

Related Errors and Solutions

Error 1201 (HY000): Could not find end of relay log - occurs when a relay log is truncated; fix by running RESET SLAVE.

Error 1594 (HY000): Relay log read failure - often follows ER_NO_UNIQUE_LOGFILE if lingering files are corrupt; resync replication.

.

Common Causes

Related Errors

FAQs

Does RESET MASTER always fix ER_NO_UNIQUE_LOGFILE?

RESET MASTER deletes all binary logs and restarts numbering, so it resolves filename collisions on a primary but removes point-in-time recovery history.

Is it safe to delete relay-log files manually?

Yes, on stopped replicas. Stop the replica, remove relay-log* files and the index, then start replication so MySQL recreates them.

How can Galaxy help prevent this error?

Galaxy stores versioned server configuration scripts and SQL snippets, letting teams document correct log settings and automate PURGE commands, reducing risk of filename collisions.

What permissions does MySQL need for log directories?

The mysqld OS user must have read, write, and execute permissions on the directory and files. Use chown mysql:mysql /path and chmod 750 /path.

Start Querying with the Modern SQL Editor Today!
Welcome to the Galaxy, Guardian!
You'll be receiving a confirmation email

Follow us on twitter :)
Oops! Something went wrong while submitting the form.

Check out some other errors

Trusted by top engineers on high-velocity teams
Aryeo Logo
Assort Health
Curri
Rubie Logo
Bauhealth Logo
Truvideo Logo