This guide explains how to enable or configuring the error log in MySQL® or MariaDB.
If MySQL is not logging errors or is saving them in an unexpected location, it may be due to incorrect or missing configurations in the MySQL configuration file. Setting the error log path explicitly guarantees that errors are properly recorded for troubleshooting.
To configure the MySQL/MariaDB error log, follow these steps:
For MySQL:
- Log in to your server through SSH as the “root” user or use WHM’s Terminal feature.
- Open the /etc/my.cnf file using a text editor like nano or vi:
nano /etc/my.cnf
- Under the [mysqld] section, add the subsequent line:
log-error=/var/log/mysqld.log
- Save the file and restart MySQL using:
/scripts/restartsrv_mysql
For MariaDB:
- Log in to your server through SSH as “root” or use WHM’s Terminal feature.
- Open the /etc/my.cnf file in a text editor:
nano /etc/my.cnf
- Under the [mariadb] section, add this line:
log_error=/var/log/mysqld.log
- Save the file and restart MariaDB using:
/scripts/restartsrv_mysql
By following these steps, you ensure that MySQL/MariaDB logs errors correctly, making debugging and troubleshooting more efficient.
For a detailed setup, check out The procedure of MySQL® 8 enabling new installations