Query logs are very useful, as they provide the record of the queries executed against the databases. These can help the programmers, Database developers and Administrators as well in trouble shooting the problems that sometimes arise. Additionally, these logs also play a very vital role in a scenario where transactions are performed against the database very much frequently for example in the case of banks, airlines etc.
In MySQL, query log feature is not enabled by default; however we can enable it through just some simple steps. So in this tutorial we will focus on the same task, which would be to enable MySQL query Log.
Step 1- Opening My.ini File
To enable mysql query logging, just open up the my.ini file from the MySql Folder through the Wamp icon located in the taskbar
![My.ini File My.ini File](https://howtech.tv/wp-content/images/003109/1.jpg)
Step 2- Specifying Log File Name
Navigate to the end of the page, and just add the following line:
Log=file_log.log
Here, file_log is the filename, it can be any name over here but .log should be the extension of all the log files.
Now just save the file and then close it.
![Modifying my.ini file and Saving it Modifying my.ini file and Saving it](https://howtech.tv/wp-content/images/003109/2.jpg)
Step 3- Restarting WAMP
Restart the Wamp services for the changes to take effect. For that, click on Wamp Server icon located on the taskbar usually, and click “Restart All Services” option.
![Restarting Services Restarting Services](https://howtech.tv/wp-content/images/003109/3.jpg)
Step 4- Opening MySQL Console
Having done that, let’s open up the MySQL console to write a query to see whether it’s logged or not.
For that, click on Wamp Server, move to MySQL folder and then choose MySQL console option from the list.
![MySQL Console MySQL Console](https://howtech.tv/wp-content/images/003109/4.jpg)
Step 5- Writing a simple query
Now let us just write a simple query just to check whether mysql query logging has been enabled or not.
![Writing Query to check The Log Writing Query to check The Log](https://howtech.tv/wp-content/images/003109/5.jpg)
Step 6- navigating inside MySQL directory
To view the log file, open up the Data Folder in the MySQL directory.
In this folder, we will find and open the log file that we specified earlier.
![MySQL directory MySQL directory](https://howtech.tv/wp-content/images/003109/6.jpg)
Step 7- Verify the Log
Once we open up the log file, you can see that all the details regarding the query that we entered are logged here.
![Queries being logged Queries being logged](https://howtech.tv/wp-content/images/003109/7.jpg)
And this is how we can enable mysql query log.