How to view the MySQL or MariaDB server error log

The MySQL and MariaDB server error log is the quickest way to explain startup failures, crash recovery, plugin problems, and configuration mistakes because the database daemon writes its own diagnostics there before most client tools can say anything useful.

The server decides the error log destination through log_error. Current MySQL shows stderr when the default destination is the console and shows a file name when logging goes to disk, while MariaDB on Unix can leave log_error blank when it is writing to stderr. Relative log paths are resolved from datadir, and systemd-managed installs usually surface stderr output through the journal.

Reading the log commonly needs root or service-level access, and the entries can expose hostnames, paths, account names, plugin names, and fragments of failing statements. Package layouts and unit names differ by distribution, so the active log may be in the systemd journal, under /var/log/mysql/, in /var/log/mysqld.log/, or in a file below the database data directory. Rotated logs may also be compressed, which matters when the failure happened earlier than the current run.

Steps to view the MySQL or MariaDB server error log:

  1. Identify the database service unit name on the host.
    $ systemctl list-unit-files --type=service | grep --extended-regexp '^(mysql|mariadb|mysqld)\.service'
    mysql.service                                enabled         enabled

    Use the unit name shown on the left in later journalctl commands. Replace mysql.service with mariadb.service or mysqld.service when that is the active unit on the host.

  2. Query the server for the current error log destination and data directory.
    $ mysql --batch --skip-column-names --execute "SHOW VARIABLES LIKE 'log_error'; SHOW VARIABLES LIKE 'datadir';"
    log_error	stderr
    datadir	/var/lib/mysql/

    Use sudo mysql on socket-auth installs or add --user and --password for password-auth setups. On MariaDB hosts that ship the client as mariadb, run the same query with mariadb instead of mysql.

    MariaDB on Unix can return a blank log_error value when the server is writing to stderr. Treat an empty result the same way as stderr and read the service journal or the process supervisor output.

  3. Read recent error-log lines from the systemd journal when log_error is stderr or blank.
    $ sudo journalctl --unit=mysql.service --no-pager --lines=20
    Apr 09 15:06:16 dbhost systemd[1]: Starting mysql.service - MySQL Community Server...
    Apr 09 15:06:17 dbhost mysqld[966]: CA certificate ca.pem is self signed.
    Apr 09 15:06:17 dbhost mysqld[966]: Channel mysql_main configured to support TLS. Encrypted connections are now supported for this channel.
    Apr 09 15:06:17 dbhost mysqld[966]: /usr/sbin/mysqld: ready for connections. Version: '8.4.8'  socket: '/var/run/mysqld/mysqld.sock'  port: 3306  MySQL Community Server - GPL.

    If the server will not start, this journal view is usually the first reliable place to look because the SQL query in the previous step needs a running daemon.

    Containerized deployments that keep stderr attached expose the same stream through docker logs <container> or podman logs <container> instead of journalctl.

  4. Follow the live error stream while reproducing the problem.
    $ sudo journalctl --unit=mysql.service --follow
    Apr 09 21:28:38 dbhost mysqld[966]: Access denied for user 'root'@'localhost' (using password: NO)

    Press Ctrl+C to stop the live stream after the relevant failure or warning appears.

  5. Read a file-backed error log when log_error returns a file name.
    $ sudo tail --lines=20 /var/log/mysql/error.log
    2026-04-09T15:06:16.843757Z 0 [System] [MY-010116] [Server] /usr/sbin/mysqld (mysqld 8.4.8) starting as process 1
    2026-04-09T15:06:17.527878Z 0 [Warning] [MY-010068] [Server] CA certificate ca.pem is self signed.
    2026-04-09T15:06:17.534802Z 0 [Warning] [MY-011810] [Server] Insecure configuration for --pid-file: Location '/var/run/mysqld' in the path is accessible to all OS users. Consider choosing a different directory.
    2026-04-09T15:06:17.557042Z 0 [System] [MY-010931] [Server] /usr/sbin/mysqld: ready for connections. Version: '8.4.8'  socket: '/var/run/mysqld/mysqld.sock'  port: 3306  MySQL Community Server - GPL.

    If log_error returns a relative name such as mysqld.err or ./mysqld.err, prepend the datadir value from the previous SQL query. For example, datadir=/var/lib/mysql/ plus mysqld.err resolves to /var/lib/mysql/mysqld.err/.

  6. Follow a file-backed error log across log rotation.
    $ sudo tail -F /var/log/mysql/error.log
    2026-04-09T15:06:17.557042Z 0 [System] [MY-010931] [Server] /usr/sbin/mysqld: ready for connections. Version: '8.4.8'  socket: '/var/run/mysqld/mysqld.sock'  port: 3306  MySQL Community Server - GPL.

    Use tail -F instead of tail -f when logrotate may rename the file while monitoring is active.

  7. List rotated error logs when the incident happened before the current file.
    $ sudo ls -lh /var/log/mysql/error.log*
    -rw-r----- 1 mysql adm  17K Apr  9 15:42 /var/log/mysql/error.log
    -rw-r----- 1 mysql adm 4.1K Apr  9 15:06 /var/log/mysql/error.log.1
    -rw-r----- 1 mysql adm 1.2K Apr  8 03:17 /var/log/mysql/error.log.2.gz

    Use zless, zgrep, or gunzip -c to inspect compressed .gz rotations without replacing the original archive.

  8. Query recent error events through SQL on MySQL when host log-file access is restricted.
    $ mysql --table --execute "SELECT LOGGED, PRIO, ERROR_CODE, DATA FROM performance_schema.error_log ORDER BY LOGGED DESC LIMIT 5;"
    +----------------------------+---------+------------+-------------------------------------------------------------------------------------------------------------------------------------------------------+
    | LOGGED                     | PRIO    | ERROR_CODE | DATA                                                                                                                                                  |
    +----------------------------+---------+------------+-------------------------------------------------------------------------------------------------------------------------------------------------------+
    | 2026-04-09 15:06:17.557140 | System  | MY-011323  | X Plugin ready for connections. Bind-address: '::' port: 33060, socket: /var/run/mysqld/mysqlx.sock                                                   |
    | 2026-04-09 15:06:17.557042 | System  | MY-010931  | /usr/sbin/mysqld: ready for connections. Version: '8.4.8'  socket: '/var/run/mysqld/mysqld.sock'  port: 3306  MySQL Community Server - GPL.           |
    | 2026-04-09 15:06:17.534802 | Warning | MY-011810  | Insecure configuration for --pid-file: Location '/var/run/mysqld' in the path is accessible to all OS users. Consider choosing a different directory. |
    | 2026-04-09 15:06:17.528103 | System  | MY-013602  | Channel mysql_main configured to support TLS. Encrypted connections are now supported for this channel.                                               |
    | 2026-04-09 15:06:17.527878 | Warning | MY-010068  | CA certificate ca.pem is self signed.                                                                                                                 |
    +----------------------------+---------+------------+-------------------------------------------------------------------------------------------------------------------------------------------------------+

    The performance_schema.error_log table is available on current MySQL builds that have compatible error-log sinks enabled. MariaDB does not expose the same table, so use the journal or file path on MariaDB systems.