2

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?

3 Answers 3

4

Use this query to get the argument as text:

select a.*, convert(a.argument using utf8) from general_log a;
3

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.

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.