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.