How to extract all IDs accessed from a mysql general log using the linux commandline?

Posted by shlomoid on Stack Overflow See other posts from Stack Overflow or by shlomoid
Published on 2011-01-10T14:44:56Z Indexed on 2011/01/10 14:53 UTC
Read the original article Hit count: 265

Filed under:
|
|
|
|

This should be a trivial question for anyone who's good with bash/sed/awk. Unfortunately, I'm not, yet :)

I've got a general log from MySQL which contains some queries that have a common parameter, they query on a specific id field. The queries look like

update tbl set col='binary_values' where id=X;

I need to process the log and extract all the IDs that these queries touched, each in it's own line. The purpose of this is to figure out how many times each ID is accessed. Eventually I'd group and count the values. The binary values are indeed binary junk, so they kinda messed up some things I've been trying to do.

Eventually we solved the problem temporarily using a python script, but I'm sure the linux command line tool set can do it too. How would you do it?

© Stack Overflow or respective owner

Related posts about mysql

Related posts about bash