Cpanel comes with a Mysql error in the server. This section allows you to view the error generated by your website.
In this article, we will review how to view your Mysql error logs from within cPanel. For more assistance, you can take our technical support team help to fix the issue on your behalf as a part of Cpanel server management services.
In some cases, the error log itself goes missing or displays some error on the screen. Let’s have a peek at the topic.
Enabling MySQL Error Log cPanel
The Log files play a vital role while troubleshooting Mysql errors on Cpanel.
Investing the reason behind the issue for the MySQL error and any other unexpected trouble that causing the error. Enable the MySQL Error log in the Cpanel is very necessary.
The default path of MySQL error log is /var/lib/mysql/{SERVER_NAME}.err
Usually, the MySQL logs will be saved automatically in the location
/var/lib/mysql. All the error log contents store in the file /var/lib/mysql/hostname.err. The hostname is the name of the account.
As prefer, you can change the filename and also the location.
Use the following code in order to add the configuration file.
[mysqld]
log_error = /var/log/mysql/error.log
Here, you can suggest a different name for the file instead of error.log as a default. With the permissions and ownership, you can create the file by using the following commands.
cd /var/lib/mysql
touch error.log
chmod 660 error.log
chown mysql:mysql error.log
Finally, you can restart the MySQL service by running the command.
systemctl start mysqld
Fixing common errors related to MySQL error log cPanel.
Let’s see how to fix the MySQL error logs on the cPanel.
Error log file unavailable
One of our client reports displays that the MySQL error is not found in the log file and also mentioned that the error log file generated in the my.cnf file. Try to troubleshoot the issue by checking the code which was set in my.cnf file. Run the code.
[mysqld_safe]
err-log=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid
The error logs of MySQL actually logs in the path /var/lib/mysql/{SERVER_NAME}.err. If you prefer to change the name or location you need to set them in the error log which is mentioned under [mysqld] section and not under the [mysqld_safe] section. Use the below code.
log-error=/var/lib/mysql/error.log
Or instead of error.log, a different name can be set with the right permissions and ownership:
cd /var/lib/mysql
touch error.log
chmod 660 error.log
chown mysql:mysql error.log
However, the default MySQL errors stores in /var/lib/mysql/{SERVER_NAME}.err itself.
Later, restart the MySQL service by using the following command
systemctl start mysqld
Finally, we can see the log file in the desired location.
Conclusion
From this blog, you can learn how to check the MySQL error logs and the root causes for MySQL errors, crashes and other unexpected behavior from MySQL. You can take our expert team assistance to fix the error.