3

When I enable sql logging to table like this:

set global log_output = 'table'
set global general_log = 'on'

Do some queries then look at the log table like this:

select * from mysql.general_log 
order by event_time desc

I don't see my sql. I see hex numbers like this in the argument field or blank ('') and no SQL at all:

0x53484F5720435245415445205441424C4520606D7973716C602E6067656E6572616C5F6C6F6760

What is going wrong?

John Little
  • 223
  • 1
  • 3
  • 11

3 Answers3

4

Use this query to get the argument as text:

select a.*, convert(a.argument using utf8) from general_log a;
ssh
  • 156
  • 1
4

This query below shows the human readable query logs of argument column:

SELECT CONVERT(argument USING utf8) FROM mysql.general_log;
1

This is simply the hexadecimal representation of the query ASCII string:

$ python -c 'print "53484F5720435245415445205441424C4520606D7973716C602E6067656E6572616C5F6C6F6760".decode("hex")'
SHOW CREATE TABLE `mysql`.`general_log`

If you check the output of the SHOW CREATE TABLE command which you apparently executed, you'll see that the argument column data type is mediumblob, which is a binary format and is therefore printed as a hex string.

mysql CLI should translate such strings automatically; I suspect the client software you're using is not doing that.

mustaccio
  • 28,207
  • 24
  • 60
  • 76