How to Enable MySQL Query Log

To enable MySQL query log follow the given steps:

Step 1. Edit MySQL Configuration

  • Open the MySQL server configuration file (my.cnf or my.ini).
  • Locate the [mysqld] section.
  • Add or modify the following directives:

[mysqld]
general_log = 1
general_log_file = /path/to/query_log.log

  • Save and close the configuration file.

2. Restart MySQL Server

  • Restart the MySQL server to apply the changes.

# Example for Linux
$ sudo service mysql restart
# Example for Windows
# Restart MySQL service using service management tools

How to Enable MySQL Query Log?

Enabling the MySQL Query Log is a crucial aspect of database administration, providing valuable insights into the executed queries, their performance, and potential issues. The query log captures SQL statements, making it an indispensable tool for troubleshooting, optimization, and auditing.

In this article, we will learn the process to enable MySQL Query Log, covering the main topic, and syntax, and providing working examples to illustrate its practical implementation.

Similar Reads

Enabling MySQL Query Log

Enabling the MySQL Query Log is a useful way to keep track of the SQL statements executed on your MySQL server. This query log can be instrumental in troubleshooting, performance optimization, and security analysis....

How to Enable MySQL Query Log

To enable MySQL query log follow the given steps:...

Enable MySQL Query Log Example

Let’s look at some examples, where we will learn how to enable MySQL query log....

Conclusion

So, overall, to enable the MySQL Query Log is an important practice for database administrators and developers. It provides a detailed record of executed queries, aiding in performance optimization, debugging, and auditing....