I use this approach:
- Copy the contents of confidential tables to a temporary table.
- Clear / encrypt sensitive columns.
- Provide the
--ignore-table mysqldump.exe arguments to leave the original tables.
It stores foreign keys, and you can store columns that are not sensitive.
The first two actions are contained in the stored procedure, which I call before executing the dump. It looks something like this:
BEGIN truncate table person_anonymous; insert into person_anonymous select * from person; update person_anonymous set Title=null, Initials=mid(md5(Initials),1,10), Midname=md5(Midname), Lastname=md5(Lastname), Comment=md5(Comment); END
As you can see, I am not clearing the contents of the fields. Instead, I save the hash. That way, you can still see which lines have the same value, and between exports you can see if something has changed or not, and no one can read the actual values.
source share