Wednesday, August 28, 2013

Enable log slow query mysql

In order to enable slow query logs for MySQL on your system you would need to do the following.
1st Step is to edit your my.cnf file which is located in your /etc directory.
vi /etc/my.cnfPlain Text
Once you have your my.cnf file open, then add the following 4 lines then save and exit the file.
[mysqld]
log-slow-queries
log-slow-queries=/var/log/mysql/slow-queries.log
long_query_time=1
Plain Text
Then create the file slow-queries.log. You can have the file in any spot you wish, as long as you define the path in your my.cnf.
touch /var/log/mysql/slow-queries.logPlain Text
Change the ownership of the file to be owned by MySQL.
chown mysql.mysql /var/log/mysql/slow-queries.logPlain Text
Lastly, you will need to restart mysqld for your changes to take place.
service mysqld restartPlain Text

Now you should have slow query logs enabled catching any MySQL query that took longer then 1 second to process.

Related Posts:

  • Install Postfix Mail Server with Dovecot and Squirrelmail on CentOS 6.4Postfix is a free open source mail transfer agent (MTA). It is easy to administer, fast and as well as secure MTA. Its a alternative to Sendmail which is the default MTA for RHEL. Prerequisites 1. Remove default MTA sendma… Read More
  • Disable module apache#LoadModule auth_basic_module modules/mod_auth_basic.so#LoadModule auth_digest_module modules/mod_auth_digest.so#LoadModule authn_file_module modules/mod_authn_file.so#LoadModule authn_alias_module modules/mod_authn_alias.so#… Read More
  • Copy a folder linux I'm a new Linux user. How do I copy a directory or folder under Linux operating system using command line options and bash shell?You can use various command to copy a folder under Linux operating systems. cp Command cp … Read More
  • Enable log slow query mysqlIn order to enable slow query logs for MySQL on your system you would need to do the following. 1st Step is to edit your my.cnf file which is located in your /etc directory. vi /etc/my.cnfPlain Text Once you have your my.cnf… Read More
  • Crontab trên Linux 1. Cron là gì? Cron là một tiện ích cho phép thực hiện các tác vụ trên hệ thống một cách tự động theo định kỳ, ở chế độ nền của hệ thống. Chức năng này khá phong phú cho phép thiết lập tác vụ dưới dạng command đơn hoặc… Read More