How does centos7 open mysql log
This post is about how centos7 opens mysql logs. Xiao Bian thinks it is quite practical, so share it for everyone to make a reference. Let's follow the editor and have a look.
In the mysql configuration file (/etc/my.cnf) write:
general_log=1
general_log_file=/log/general.log
slow_query_log=1
slow_query_log_file=/log/slowqueries.log
long_query_time=5
log_output='FILE,TABLE'
The above configuration functions are:
general_log=1 Open general log
general_log_file=/usr/local/mysql/mysql-5.7.22/log/general.log
slow_query_log=1 Open slow query log
slow_query_log_file=/usr/local/mysql/mysql-5.7.22/log/slowqueries.log
long_query_time=5 Slow query threshold
log_output='FILE,TABLE' output mode, FILE means file, TABLE means database (you can see the log in mysql library), can be used at the same time, the method above, can also be used alone such as log_output='FILE'. Output to files is more efficient than output to databases.
Note: mysql does not take the initiative to create log files, so you need to add them manually. After adding them, all users are given readable and writable permissions, chmod 777 log files, otherwise they will report permission denied.
Restart mysql after modification: systemctl restart mysqld
Thank you for reading! About centos7 how to open mysql log to share here, I hope the above content can be of some help to everyone, so that everyone can learn more knowledge. If you think the article is good, you can share it so that more people can see it!