Intellipaat Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in SQL by (6.1k points)
How can I possibly enable the MySQL function that will be logging each and every SQL query statements acquired from the clients and further the timestamp that the query statement has been submitted?

Would I be doing it in the PHPMyAdmin or in the Navicat and also how to examine those logs?

1 Answer

0 votes
by (12.7k points)

First, Keep in mind that this log file can grow very large on a busy server.

For mysql < 5.1.29:

In order to enable the query log, put this in /etc/my.cnf in the [mysqld] section

log   = /path/to/query.log  #works for mysql < 5.1.29

Also, to enable it from the MySQL console

SET general_log = 1;

For MySQL 5.1.29+

With MySQL 5.1.29+, the log option is deprecated. To determine the log file and enable logging, use this in my.cnf in the [mysqld] section:

general_log_file = /path/to/query.log
general_log      = 1

On the other hand, for turning on logging from the MySQL console (should further specify the log file location anyhow, or find the default location):

SET global general_log = 1;

Additionally, note that there are further options to log only slow queries or those which do not use indexes.

Willing to Learn SQL? Come and Join the SQL Certification course by Intellipaat.

Related questions

0 votes
1 answer
0 votes
1 answer
0 votes
1 answer
0 votes
1 answer

31k questions

32.8k answers

501 comments

693 users

Browse Categories

...