MySQL won’t start. The systemd unit reports failure. The first action is to read the error log — and on a cPanel host, the answer to “where is the error log” depends on which version of cPanel, which version of MariaDB, and whether anyone customized /etc/my.cnf. The wrong tail on the wrong file produces stale information from last week’s restart and sends you debugging in the wrong direction. The right path is one of three places, and SHOW VARIABLES won’t help you when MySQL won’t start.
What’s happening
The MySQL error log location is controlled by log_error in /etc/my.cnf (or /etc/my.cnf.d/cpanel.cnf). cPanel doesn’t set this by default, so MySQL uses its compiled-in default. The default differs by build:
- MariaDB on AlmaLinux/CentOS via cPanel:
/var/lib/mysql/$(hostname).err(the hostname-prefixed file in the data directory). - MySQL 8.x:
/var/log/mysqld.logif the systemd unit sets it, or/var/lib/mysql/$(hostname).err. - If
log_erroris set in config: whatever that path says. - If
mysqldis started withoutlog_errorand not via systemd: stderr, which usually means the systemd journal.
When MySQL won’t start, none of mysql -e "SHOW VARIABLES" work — the daemon isn’t there to answer. You have to find the log by checking each likely path.
How to verify
When MySQL is running:
mysql -e "SHOW VARIABLES LIKE 'log_error'"
When MySQL is not running:
grep -E "log_error|log-error" /etc/my.cnf /etc/my.cnf.d/*.cnf 2>/dev/null
ls -la /var/lib/mysql/*.err
ls -la /var/log/mysql*
journalctl -u mariadb --since "10 minutes ago"
journalctl -u mysqld --since "10 minutes ago"
hostname
If log_error is configured, that’s the path. If not, check /var/lib/mysql/$(hostname).err. If that’s empty or stale, check the journal (modern cPanel uses systemd, which captures stderr).
The fix
- For a daemon that won’t start, walk the candidate paths in this order:
/var/lib/mysql/$(hostname).err— most common on cPanel + MariaDB.journalctl -u mariadb -p err --since "10 minutes ago"— what systemd captured./var/log/mysql/error.log— if cPanel was customized./var/log/mysqld.log— if MySQL 8.x with default systemd unit. The first one with recent timestamps and ERROR lines is your log.
- Once found, the most common reasons MySQL won’t start:
[ERROR] InnoDB: Plugin initialization aborted: usually a redo log corruption after unclean shutdown. Solution:innodb_force_recovery = 1to bring it up, then dump/restore.[ERROR] Could not open the mysql.plugin table: system tables corrupted. Runmysql_upgradeafter starting with--skip-grant-tables.Can't open and lock privilege tables: Table 'mysql.plugin' doesn't exist: same. Runmysql_upgrade --force.Address already in use: another mysqld is running.ps aux | grep mysqlto find it.out of memory:dmesg | tailwill show the OOM kill. Free memory or raise it.
- Set
log_errorexplicitly to take this guesswork off future incidents. In/etc/my.cnf.d/cpanel.cnf:[mysqld] log_error = /var/log/mysql/error.logmkdir /var/log/mysql && chown mysql:mysql /var/log/mysqlfirst. Restart MySQL once it’s up. - Add log rotation. Without it, the error log can reach 500MB before anyone notices:
/etc/logrotate.d/mysql-error: /var/log/mysql/error.log { weekly rotate 4 missingok compress delaycompress notifempty postrotate mysqladmin flush-logs endscript } - For a verbose error log on a noisy host, raise the log level temporarily:
SET GLOBAL log_warnings = 2(MySQL 5.7) orSET GLOBAL log_warnings = 3. Reverts on restart unless persisted. - For real-time tailing during an incident:
tail -F /var/log/mysql/error.log(capital F follows the log through rotation).
For environments where MySQL diagnostic friction matters, Stack Harbor’s environment management team standardizes log paths across hosts and ships log shipping to a central aggregator so the “where is the log” step is gone.