Got stumbled by any MySQL error and would like to view the error log in CPanel to find the reason for it?
MySQL error logs provide the exact reason behind any MySQL error. Referring to this, we can fix any MySQL errors in the server.
However, there can be cases where the error log itself goes missing or show up some problems.
Here at Bobcares, we receive requests to enable the MySQL error log cPanel and check its issues as a part of Server Management Services for web hosts and online service providers.
Today, let’s see how our Support Engineers enable the MySQL error log and fix its related errors.
How to enable MySQL Error Log cPanel?
Log files play a vital role during troubleshooting any error. We can investigate the root causes for MySQL errors and any unexpected trouble related to it through MySQL error log cPanel. So, it is necessary to enable the MySQL Error log cPanel.
Now let’s see how our Support Engineers enable the error log.
The default path of MySQL error log is /var/lib/mysql/{SERVER_NAME}.err
Generally, the MySQL logs automatically save in the location /var/lib/mysql. Also, all the error log contents store in the file /var/lib/mysql/hostname.err. The hostname is the name of the account. We can change this filename if necessary and also provide a different location as well.
Below is the code that we add to the configuration file.
[mysqld]
log_error = /var/log/mysql/error.log
Here, a different name can be set for the file instead of error.log. We create that file with the right permissions and ownership using the below commands:
cd /var/lib/mysql
touch error.log
chmod 660 error.log
chown mysql:mysql error.log
Finally, we can restart the MySQL service using the command:
systemctl start mysqld
Common errors related to MySQL error log cPanel and its fixes.
Now, let’s see some errors related to MySQL error logs and how our Support Engineers fix them.
1. Error log file unavailable
One of our customers approached us telling us that he was not able to find the MySQL error log file.
Also, he mentioned about the error log file generation in my.cnf file.
So, our Support Engineers started troubleshooting the issue by checking the code which was set in my.cnf file. The code was as below
[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 a different name or location needs to be set then the error log must be mentioned under [mysqld] section and not under the [mysqld_safe] section. And the below code can be put within it:
log-error=/var/lib/mysql/error.log
Or instead of error.log, a different name can be set. Our Support Engineers created that file 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.
Then, we restarted the MySQL service using the below command:
systemctl start mysqld
Finally, the customer was able to find the desired error log file in the desired location.
[Need more assistance with MySQL error logs? – We’ll help you]
Conclusion
In short, we can check the MySQL error logs to know the root causes for MySQL errors, crashes and other unexpected behavior from MySQL. Today, we learned about MySQL error logs and its errors and how our Support Engineers fix it.
0 Comments