John John - 6 months ago 29
SQL Question

Format MySQL query log date

I've enabled MySQL query logging

general_log_file = "C:/mysql/logs/queries.log"
log-bin = "C:/mysql/logs"
general_log_file = "C:/mysql/logs/queries.log"
log-warnings = 1
general-log


However the date format is not conductive to quick visual interpretation:

160509 16:27:33 1871 Connect db@localhost on db_name
160509 16:27:36 1872 Connect db@localhost on db_name


How can I format the date stamp in the MySQL query log?

In example:

2016-05-09 16:27:33 1871 Connect db@localhost on db_name
2016-05-09 16:27:36 1872 Connect db@localhost on db_name

Answer

MySQL release 5.6.9 changed the log formatting from YYMMDD to YYYY-MM-DD. Looks like your option is to upgrade.