Hello,

I have large MySQL dump files formatted as a set of SQL statements. The statements are the ones to set up the database structures and then to insert data into tables.

I need to process data in the files, remove sensitive data from certain columns, replace it with something other which looks like a valid data for each corresponding column, but doesn't contain any sensitive details. The output is going to be in the same format -- SQL formatted MySQL dump file.

This needs to be done without loading the contents of dump file into any database.

Looks like feasible. We read the file, recognize where the data fields start and end in the stream and replace those pieces of data with another data -- the 'anonymized' one.

The difficulties start with the realization that all the data in the INSERT statement is one long line with no end-of-line characters. Not a row of data per line -- just one long line which represents all data as ('column1', 'column2'),('a','b'),('something','something other') ...

Another piece of complexity comes with the realization that the data can contain embedded quotes, commas and parentheses.

The size of data being processed is much greater than the amount of RAM available on the machine which is doing the processing.

Can you please suggest some ideas about the possible implementation?

Thank you


In reply to Masking data in a MySQL dump file. Ideas? by dliakh

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.