0

Is there a way I can find out how many select, update, insert and rest of the queries have been executed by MySQL server ? Can it be in last 1 day or week ?

2 Answers 2

1

Yes, there is a way! You can set the server to write logs about client connects/disconnects and every statement which was executed to a log file. Have a look here.

Sign up to request clarification or add additional context in comments.

3 Comments

thanks for the answer. is it recommended to keep it on during production environment always ?
Sure, if you want to log the queries in some way, it has to. If you need it to inspect a particular error, you can turn it on just for the duration you need it to. Anyways, it's a good position for you to have an insight what queries are executed on your machine for troubleshooting.
i didnt know much about these concept as I am new to this site. but I am getting answers pretty immediately. let me accept answers from now on :)
1

Start General Query Log, it allows storing log info into table.

Then write a SELECT query to read data from mysql.general_log table, add WHERE condition to filter result by date. Then analyze (parse) data from the argument field, it contains executed queries.

2 Comments

thanks for the answer. is it recommended to keep it on during production environment always ?
Agree with stb about using query log. Turn on it just for the debugging purposes.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.