Driver FixRecommendedSound, Wi-Fi or graphics acting up? Check drivers firstFind missing or outdated drivers fast.Check DriversHalloween DealsAmazon USHalloween week deals: useful picks before month-endAmazon US: current deals, useful picks and tech finds.Check DealsSlow PC?RecommendedPC slow today? Run a repair scan before it gets worseResolve common Windows issues and optimize system performance.Scan Now×
Skip to content
VGSources
Blog

How to Find and Read MySQL Error Logs (Linux, Windows, and SQL)

MySQL error logs do not have one universal location. Learn how configuration chooses the destination, how to find it on Unix-like systems and Windows, how to query recent entries in MySQL 8.4, and how to interpret startup, runtime, and shutdown messages.
Length10 min Posted Quest giverVGSources Team
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

There is no single universal MySQL error-log path. The active destination is chosen by the server’s startup options and logging configuration: it may be the console, a host_name.err file in the data directory, an explicitly named file such as /var/log/mysqld.log, a system log, or (in MySQL 8.4) a bounded Performance Schema table. Find the configured destination first, then read the newest entries around the time of the failure.

What the MySQL error log contains

The error log is the server’s diagnostic record. MySQL’s 8.4 documentation describes it as containing a record of mysqld startup and shutdown times, plus diagnostic messages such as errors, warnings, and notes produced during startup, shutdown, and normal operation. It is the first place to look when the server will not start, stops unexpectedly, cannot bind its port, cannot open a file, or reports storage-engine recovery.

As an Amazon Associate I earn from qualifying purchases.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

The log is not the same thing as a query or replication log. It generally tells you what the server and its components encountered, rather than providing a complete history of every SQL statement.

Log What it records Use it for
Error log Startup and shutdown records, runtime warnings, errors, and notes Startup failures, crashes, permissions, ports, recovery, configuration problems
General query log Connections and SQL statements as they are received Tracing activity or finding a statement associated with a failure
Slow query log Statements that exceed the configured execution threshold Performance investigation
Binary log Changes recorded for replication and point-in-time recovery Replication, recovery, and change history
Relay log Events received by a replication replica Replica execution and transport problems
DDL log Data-definition operations used by MySQL’s recovery mechanisms Diagnosing interrupted DDL work

If you need to prove which SQL statement preceded a crash, that is a separate investigation. MySQL’s log-file troubleshooting guidance explains how to enable the general query log and inspect its end; do not expect the error log alone to contain every query. See MySQL 8.4: Using Log Files.

Find the active destination on Linux and other Unix-like systems

Do not start by guessing a path. Ask the running server which error-log destination it is using, then check whether the value names a file, standard error, or a system logging facility.

1. Query the server configuration

SHOW VARIABLES LIKE 'log_error';
SHOW VARIABLES LIKE 'datadir';

Run these statements in a MySQL client with an account allowed to read server variables. log_error identifies the configured destination, while datadir gives you the fallback directory in which a default .err file may reside.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

2. Apply MySQL’s destination rules

Configuration Result on Unix-like systems
No --log-error option Messages go to the console by default.
--log-error with no filename MySQL uses host_name.err in the data directory.
--log-error=/path/to/file Messages go to that file. An absolute path can place it outside the data directory.
log_error reports stderr Read the service manager’s captured standard error or the host’s system log rather than searching only for a file.

Distribution packages often set an explicit file under /var/log, such as /var/log/mysqld.log. That is a packaging choice, not a universal MySQL default; the value returned by log_error takes precedence over assumptions based on the operating system.

3. Open the file with the host’s tools

Once log_error returns a path, use the account that owns or is permitted to read that file. For a quick view of the newest records:

sudo tail -n 100 /path/returned/by/log_error
sudo less /path/returned/by/log_error

With less, press G to jump to the end, then search with / for a timestamp, an error code, ERROR, Warning, or a component name. If the file is rotated, inspect the current file first and then the appropriately dated compressed or archived files managed by your operating system.

4. Follow a systemd service when the destination is not a file

Package conventions commonly name the systemd unit mysqld on RPM-based systems and mysql on Debian-based systems. Use the unit that exists on your host:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
sudo systemctl status mysqld
sudo systemctl status mysql
sudo journalctl -u mysqld --since "1 hour ago"
sudo journalctl -u mysql --since "1 hour ago"

Do not run both journal commands blindly; select the service name shown by your installation. If the service status says output is being sent to standard error, or log_error is stderr, the journal (or another configured system logger) is the destination. systemctl status also reveals immediate startup failures and the command line used to launch the service, which can expose an unexpected configuration file or --log-error option.

When the server will not start

You may not be able to run SHOW VARIABLES if mysqld never reaches a state in which it accepts connections. In that case, inspect the service definition and startup command, then check the data directory named by the configuration. Look for a recent host_name.err, an explicitly configured log path, or service-manager output. A failed start often leaves the decisive message in the first few lines written during that attempt, so compare the timestamp with the latest start command.

Find the error log on Windows

On Windows, the normal file destination is also configuration-dependent. Unless --console is used, MySQL sends diagnostic output to a .err file in the data directory. The --pid-file option can affect the file’s basename, and an explicit --log-error option can move it elsewhere.

1. Identify the data directory and configuration file

Check the my.ini used by the Windows service, then look for its datadir, log-error, pid-file, and any console setting. Common MSI installations place data and logs below %PROGRAMDATA%MySQLMySQL Server 8.4, or below the installation’s configured data directory. Treat that as a starting point only: local my.ini and service arguments take precedence.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
dir "%PROGRAMDATA%MySQLMySQL Server 8.4"
dir "C:pathtoyourdatadir*.err"

If you do not know the service’s configuration, open the Windows Services console, locate the MySQL service, and inspect its executable path and startup arguments. Those arguments can specify a different option file or an explicit log file.

2. Open the newest .err file

Use Notepad, a log viewer, or PowerShell to read the tail of the file:

Get-Content "C:pathtodatadirhostname.err" -Tail 100
Get-Content "C:pathtodatadirhostname.err" -Wait

The first command prints the latest 100 lines; -Wait follows new lines while the server is running. Substitute the actual filename reported by your configuration. If --console was used, there may be no useful file because diagnostics were written to the launching console instead.

3. Check Event Viewer when the Windows event-log sink is configured

MySQL can send errors to the Windows Event Log through its log_sink_syseventlog component. Open Event Viewer and inspect the Windows Logs areas, filtering around the incident time and the MySQL service name. This route is especially important when the expected .err file is absent and the service starts under a managed account with a different filesystem view.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Windows startup failures

The error log is the first resource for a Windows startup failure. Capture the exact timestamp, the first error after the attempted start, and any referenced path. Typical decisive messages identify an unreadable option, a permissions problem in the data directory, a port already in use, or recovery work after an unclean shutdown. Do not infer the path from the product’s installation directory if my.ini specifies another data directory.

Read recent errors through SQL in MySQL 8.4

MySQL 8.4 can expose recent error-log events in the Performance Schema table performance_schema.error_log when the relevant error-log sink is enabled. This is useful when an administrator can grant SQL access but should not grant shell access to log files.

SELECT *
FROM performance_schema.error_log
ORDER BY LOGGED DESC;

Start with a limited result set when the table is busy:

SELECT LOGGED, PRIO, ERROR_CODE, SUBSYSTEM, DATA
FROM performance_schema.error_log
ORDER BY LOGGED DESC
LIMIT 100;

Column availability and names should be confirmed against the MySQL 8.4 table definition on your server before building tooling around them. Granting SELECT on this table can provide controlled access without exposing the host filesystem.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Understand the retention limit

The table is a fixed-size in-memory ring buffer. As new events arrive, older rows are discarded; it is not a permanent archive and cannot replace file rotation, syslog retention, or centralized collection. If the incident happened hours or days ago, the row may already be gone even though the server is healthy now. Query the table promptly, export the relevant rows, and retain the configured file or system log for historical analysis.

When the table is empty

An empty or unavailable table does not prove that MySQL generated no errors. The required sink may not be enabled, the table may have already overwritten older events, or the account may lack permission. Return to log_error and the host’s configured destination, then verify the server’s error-log components and Performance Schema configuration.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

How to read an incident chronologically

Reading the newest line in isolation often produces a wrong diagnosis. Use a short, repeatable sequence that preserves context.

  1. Set the time window. Record when the application observed the failure, when the service was restarted, and the host’s time zone. Open entries a few minutes before and after that window.
  2. Start at the newest entries. Work backward until you reach the first message associated with the incident, rather than stopping at a later cascade of secondary warnings.
  3. Separate lifecycle messages. Mark startup and shutdown records separately from runtime warnings and errors. A clean shutdown followed by a successful startup means something different from an abrupt stop followed by storage recovery.
  4. Capture the identifying fields. Save the timestamp, priority, component or subsystem, numeric error code or symbolic name, full message, and every referenced file, directory, port, table, or plugin.
  5. Classify the failure. Decide whether the message points to permissions, an unavailable port, an invalid option, a missing file, storage-engine recovery, or an unclean shutdown. Then verify that interpretation against the surrounding entries.
  6. Check the first cause. Later messages may simply report consequences. For example, a failed option can prevent a plugin from loading, which then produces several follow-on errors. The earliest specific failure is usually the actionable one.
  7. Correlate with the host. Compare the MySQL timestamp with systemd journal entries, Windows Event Viewer records, deployment logs, disk alerts, and the application error time. A filesystem or process supervisor event can explain why MySQL stopped writing.
  8. Preserve evidence before changing settings. Copy the relevant lines and the active configuration (with passwords and secrets removed) before restarting repeatedly or rotating files.

Common message patterns

  • Permission or ownership errors: identify the exact path and the operating-system account running MySQL. Check access to every parent directory, not only the final file.
  • Port unavailable: find which process owns the configured TCP port, then decide whether to stop that process or change the MySQL port consistently for clients and firewall rules.
  • Invalid option: locate the option in the active my.ini or Unix option file and confirm spelling, section, and version compatibility before restarting.
  • Storage-engine recovery: distinguish normal recovery progress from a recovery error. Do not delete data or log files merely to make the message disappear.
  • Unclean shutdown: correlate the last clean shutdown with host power loss, process termination, an out-of-memory kill, or a forced service stop.

Compare the available destinations

Choosing where to read the log is an operational decision, not just a path lookup. The same event may be visible in more than one sink, but each has different durability and access controls.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Destination Persistence Access control Structure and retention Operational owner
Text file Persistent until rotation or deletion Filesystem permissions and service account Traditional text; retention depends on rotation and storage Database or host administrator
Console or stderr Depends on the launching process and service manager Process and service-log permissions May be ephemeral or captured by journald/Event Viewer Service manager or platform team
Syslog or Windows Event Log Depends on the host logger’s retention policy System-log permissions and centralized access rules Can be centralized and indexed; format depends on the sink Operating-system or observability team
performance_schema.error_log In-memory only SQL privileges, such as SELECT Structured rows in a fixed-size ring buffer; oldest events are discarded Database administrator

If two destinations disagree, first compare their timestamps and retention windows. A file may contain an older event that the SQL ring buffer has already discarded, while a centralized logger may add ingestion delay or normalize fields. Keep one durable destination for incident history and use SQL or the service log for fast, permission-controlled access.

When the error log is not enough

A missing explanation does not mean MySQL produced no useful evidence. It may mean that the relevant information belongs to another log or was emitted before the current destination was configured.

  • Use the general query log when you need to identify statements and connections immediately before a failure. Enable it deliberately because it can generate substantial volume and may expose sensitive SQL.
  • Use the slow query log for latency and workload problems, not for startup diagnostics.
  • Use the binary and relay logs for replication or point-in-time-recovery questions.
  • Use the systemd journal, syslog, or Event Viewer when the process was killed, the host rebooted, disk space ran out, or logging was directed to stderr.

For a crash or hang, preserve the error-log excerpt first, then examine the end of the general query log as a separate diagnostic step. Do not enable every log permanently: choose the smallest additional source that answers the unanswered question, set an explicit retention plan, and disable high-volume logging when the investigation ends.

A concise checklist

  • Query SHOW VARIABLES LIKE 'log_error'; and SHOW VARIABLES LIKE 'datadir'; when the server accepts connections.
  • If the value is a path, read that file and begin at its newest entries.
  • If it is stderr or no file exists, inspect the service manager, system log, or Windows Event Viewer.
  • On Windows, check my.ini, --console, --pid-file, and --log-error before assuming a default .err name.
  • In MySQL 8.4, query performance_schema.error_log only when its sink is enabled, and remember that the table is a bounded in-memory buffer.
  • Read around the incident time, identify the earliest specific error, and record its component, code, path, and timestamp.
  • Escalate to the general, slow-query, binary, relay, DDL, or host logs only when the error log cannot answer the remaining question.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Leave a Reply

Your email address will not be published. Required fields are marked *

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More quests from Patch Notes

  1. How to Set Up a RedM (RDR2) Server in 2026: License Key, txAdmin and server.cfg, Step by StepBlog11min
  2. Best RedM (RDR2) Server Hosting in 2026: Comparing Four Hosts on Slots, Memory and PriceBlog10min
  3. How to Host a Mindustry Server in 2026: server-release.jar, Port 6567 and the Commands That MatterBlog7min
Recommended PC Tool
Recommended PC Tool
Windows Errors? Fix Them Before They SpreadFree repair scan
Outdated Drivers Are Slowing You DownFree scan - exact matches

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.