简体   繁体   中英

MySql General Query Log File Name in Truncate

This involves MySQL 5.7 running on Windows Server 2016.

I'm working with a TRUNCATE statement in MySql to reduce the size of a large Log file (named "mySite.log"), which resides in:

ProgramData/MySQL/MySQL Server 5.7/Data/

I have researched and implemented the following:

mysql> SET GLOBAL general_log=OFF;

and this was successful.

However, I am trying to ascertain that the large log file that I see in the directory stated above is in fact the General Query Log File. It carries the name of the database as the prefix of the file name ("MySite.log") just as the other files (.bin's and .err, .pid) in the same directory do. Is this large log file actually the general_log file? (If using MySQL Workbench, where would the naming of the log file and storage location be set up? I can't seem to locate that.) Will the following syntax truncate the log file?

mysql> TRUNCATE TABLE mysql.general_log;
  1. Will 'TRUNCATE TABLE' be used, even if the log is stored in a file, rather than database table?
  2. Will 'mysql.general_log' need to be renamed to 'myDatabase.mysite' to match the name of my "MySite.log" file, from above?

Thanks for any leads.

Some interesting manual entries to read about this:

You can check how your server is configured with

SHOW GLOBAL VARIABLES LIKE '%log%';

Then look for the value of log-output . This shows if you're logging to FILE , TABLE or both.

When it's FILE , check for the value of general_log_file . This is where the log file is in your file system. You can simply remove it, and create a new file (in case you ever want to enable general_log again). Then execute FLUSH LOGS; afterwards.

When it's TABLE then your TRUNCATE TABLE mysql.general_log; statement is correct.

Regarding your second question, just never mess with the tables in the mysql schema. Just don't (if you don't know what you're doing). Also I don't even get how you got to that thought.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM