How to Enable the Query Log in MySQL

Follow this step by step easy tutorial to learn how to enable the query Log in MySQL and see how to make log file.

Don't forget to check out our site http://howtech.tv/ for more free how-to videos!
http://youtube.com/ithowtovids - our feed
http://www.facebook.com/howtechtv - join us on facebook
https://plus.google.com/103440382717658277879 - our group in Google+

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

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.

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.

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.

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.

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.

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.

Developed Strategies and Processes that Enabled Brands to Grow During an Economic Downturn.

Taught Advanced Internet Marketing Strategies at the graduate level.

Your Cart 0

Manage research, learning and skills at defaultLogic. Create an account using LinkedIn or facebook to manage and organize your Digital Marketing and Technology knowledge. defaultLogic works like a shopping cart for information -- helping you to save, discuss and share.