How to create mysql logs for specific queries

As a developers need to check the mysql logs. Many times for any request how many mysql queries are running or executed we need to know.

How to create mysql logs for specific queries.

 

How to create mysql logs for specific queries

How to create mysql logs for specific queries

In this tutorial I will show you how to created mysql log file for checking the SELECT, UPDATE, DELETE or any types of mysql queries.

If you are using the linux then use the my.cnf file which will be located in etc folder. If you are using the windows then use the my.ini file. That file you will find in following location in case of wamp server.

c:\wamp\bin\mysql\mysql5.0.45\my.ini

I am using the Linux so here I am giving that example.  use following command.

[root@siwank-pc mysql]# mkdir /var/log/mysql
[root@siwank-pc mysql]# chown mysql:mysql /var/log/mysql

[root@siwank-pc mysql]# vim /etc/my.cnf

[mysqld]
log = /var/log/mysql/mysqld.log //This log file will give you the full mysql access log

log-error=/var/log/mysql/mysqld-error.log // this log file will give you the error log of mysql

log-slow-queries=/var/log/mysql/log-slow-queries.log // this log file will give you the slow queries log

If you need the more information about mysql logs then write to me.

4 Comments

Add a Comment

Your email address will not be published. Required fields are marked *