See if I am currently capturing traffic with the General Log:
SELECT @@general_log; -- 1 if capturing, 0 if not
-- for me, a 1. This means I have been capturing (good for development. Poor idea for Production)
SELECT @@general_log_file; -- file name for General Log if capturing.
-- for me: GeneralLogBegin_20160803_1420.log
SELECT @@datadir; -- the location of the general_log, and other logs
-- for me: C:ProgramDataMySQLMySQL Server 5.6Data
Now I turn off the capturing of the General Log below, because mine was capturing:
SET GLOBAL general_log=0; -- stop logging
I MOVE my log file to a backup directory, renaming it to GL_from_20160803_1420_to_20160806_1559
There is little ambiguity to the content and datetime range of capture that the above file embodies.
Set the new name for the log file capture (Begin segment for filename)
SET GLOBAL general_log_file='GeneralLogBegin_20160806_1559.log';
SET GLOBAL general_log=1; -- Start logging again
Run an app of mine that connects to the server, and General Log contains:
ChunkA:
160806 16:08:37 170 Connect [email protected] on stackoverflow
170 Query SHOW VARIABLES
170 Query SELECT TIMEDIFF(NOW(), UTC_TIMESTAMP())
170 Query SHOW COLLATION
170 Query SET NAMES latin1
170 Query SET character_set_results=NULL
170 Init DB my_db_name
Note: you may need to do
mysqladmin -u root -p flush-log
(prompted for password) in order to flush the logs from cache to the file.
By the way, Sublime Text is awesome for auto-refresh of a text file currently loaded. Such as, a log file.
So my ChunkA
above is the connection stub of a new connection coming in. It is driven by the commands of the program in use, whatever that may be. It is prior to your program commands that you are used to and code. If you are continuously creating new connections, executing code you write, and disconnecting, well these are all part of the baggage. You are not in control of optimizing them in any simple fashion.
What you should consider doing is turning OFF the General Query log in a production environment. And only enabling it during Debug and Test environment settings. Having it on increases unnecessary burden on you stack.