Logs are the best part to start troubleshooting.In this article we will show you how to enable the different type of logs into MySQL server:
Error Log:
It contains all the information about MySQL errors.To enable MySQL error log edit MySQL configuration file and update following setting as per your requirements.
[mysqld] log_error = /var/log/mysql/error.log
General Log:
General logs contain all the records of MySQL activities like (queries , connect, disconnect) To enable general logs in MySQL, edit configuration file and uncomment following lines to enable general logs and change log file path to create log on different directory.
general_log_file = /var/log/mysql/mysql.log general_log = 1
Slow Query Log:
As indicated by its name,It consists of “slow” SQL statements.To enable Slow Query Log, uncomment or add the following line in [mysqld] section.
log_slow_queries = /var/log/mysql/mysql-slow.log long_query_time = 2 log-queries-not-using-indexes
Restart MySQL:
After making above changes, restart MySQL services by using one of the following command :
service mysql restart or systemctl restart mysql.service
Done.