You can't do this with the mysqldump
tool. It doesn't have any option for transforming the output, it only dumps the data that is in your database. So if you use mysqldump
, your options are:
- Store anonymized data and dump that data (as suggested by @DroidX86 in a comment above)
- Get really good at
sed
and use it to filter the output of mysqldump. I am really good with sed, and I wouldn't try that.
So you may try to dump data without using mysqldump
, so you have more options for custom transformations on the data.
You can write a script to SELECT ... FROM MyTable;
which is basically what mysqldump
does. But if you write your own tool, you can use expressions to anonymize the name and firstname instead of dumping the contents of those columns as-is.
However, coding your own replacement for mysqldump
is harder than it sounds. Some developers have attempted it and gotten it spectacularly wrong. I've answered questions about it before: