MYANON(1)

πŸ“¦ version 0.8.5, in nixos 26.05, nixpkgs unstable

MYANON(1) πŸ’…

okay bestie, you found the myanon page β€” the MySQL dump anonymizer that's lowkey a whole vibe. ✨

🌸 NAME 🌸

myanon β€” MySQL dump anonymizer 🫢

✨ SYNOPSIS ✨

myanon -f config_file [-d]

πŸ’– DESCRIPTION πŸ’–

okay so myanon reads a MySQL dump (the kind mysqldump(1) makes) from standard input and writes an anonymized version to standard output. no cap.

Anonymization is deterministic: it uses HMAC-SHA256 keyed by a shared secret, so identical input values always produce the same anonymized output. this preserves referential integrity across foreign keys β€” iconic behavior, honestly.

myanon works on flat (numeric and text) fields and has built-in support for JSON fields. optional Python support lets you use custom anonymization functions (e.g. using faker). πŸ’…

πŸŽ€ OPTIONS πŸŽ€

  • -f config_file β€” path to the configuration file. it's required, bestie.
  • -d β€” enable debug mode. prints debug information to standard error.
  • -v, --version β€” print version information and exit.
  • -h, --help β€” print a usage summary and exit.

πŸ¦‹ CONFIGURATION FILE πŸ¦‹

the configuration file is a text file with the following directives.

πŸ’– Global directives πŸ’–

  • secret = 'keyΒ΄ β€” HMAC secret, up to 64 characters.
  • stats = 'yes|noΒ΄ β€” when set to yes, statistics are appended as SQL comments at the end of the output.
  • pypath = 'pathΒ΄ β€” directory where the Python script is located. may be relative or absolute. the environment variable PYTHONPATH can also be used. only available when compiled with Python support (--enable-python).
  • pyscript = 'nameΒ΄ β€” name of the Python script (without the .py extension). only available when compiled with Python support.

πŸŽ€ Tables block πŸŽ€

the tables block lists tables and their anonymization rules:

tables = {
   `table` = {
     `field` = rule
     ...
   }
   `other_table` = truncate
}

table and field names are enclosed in backticks. tables may also be matched using a regular expression with the regex prefix:

regex `(prod|test)players` = {
   `lastname`  = texthash 20
   `firstname` = texthash 20
}

🌈 ANONYMIZATION RULES 🌈

the following anonymization rules are available. most rules can take an optional 'cΒ΄ suffix to handle multiple values within a single field, separated by character c. πŸ‘‘

  • texthash N β€” hash the value into a readable text string of N characters (max 32).
  • inthash N β€” hash the value into a numeric string of N digits (max 32).
  • emailhash 'domain' N β€” hash the value into an email address ending with domain, N characters long in total (max 32).
  • fixed 'valueΒ΄ β€” replace the field with a fixed value. quoting follows the field type (text fields are quoted, numeric fields are not). quoting can be overridden with the quoted or unquoted keyword before the value:
fixed 'myvalue'
fixed quoted '5'
fixed unquoted '0x1234'
  • fixed null β€” replace the field with SQL NULL.
  • key β€” tag this field as the key column. its anonymized value is remembered and can be referenced by appendkey or prependkey rules in other columns of the same table.
  • appendkey 'prefix' β€” replace the field with prefix followed by the current key value. requires a key column in the same table.
  • prependkey 'suffix' β€” replace the field with the current key value followed by suffix. requires a key column in the same table.
  • appendindex 'prefix' β€” replace the field with prefix followed by the current row index (starting at 1).
  • prependindex 'suffix' β€” replace the field with the current row index followed by suffix.
  • substring N β€” truncate the field value to the first N characters.
  • json { path 'jsonpath' = rule ... } β€” apply anonymization rules to specific paths within a JSON field. paths use dot notation for nested objects (e.g. address.street) and brackets for arrays (e.g. items[]). each path is followed by one of the rules above. example:
`data` = json {
    path 'email'           = emailhash 'example.com' 20
    path 'address.street'  = texthash 15
    path 'items[]'         = texthash 10
}
  • pydef 'function' β€” call a custom Python function for anonymization. the function must be defined in the script specified by pyscript and accept a single parameter (the value to anonymize). only available when compiled with Python support.
  • truncate β€” remove all INSERT and UPDATE statements for this table (table-level rule).

🌸 EXAMPLES 🌸

anonymize a dump file:

mysqldump mydb | myanon -f myanon.conf > mydb_anon.sql

create both a real encrypted backup and an anonymized backup from a single dump:

mysqldump mydb | \
  tee >(myanon -f myanon.conf | gzip > mydb_anon.sql.gz) | \
  gpg -e -r me@domain.com > mydb.sql.gz.gpg

✨ EXIT STATUS ✨

  • 0 β€” successful completion.
  • 1 β€” an error occurred (configuration error, parse error, etc.).

πŸ”₯ SEE ALSO πŸ”₯

mysqldump(1)

πŸ’€ BUGS πŸ’€

report bugs to <pierre.pomes@gmail.com> or at https://github.com/ppomes/myanon/issues.

πŸ‘‘ AUTHORS πŸ‘‘

Pierre Pomes.


okay bestie, that's the whole MYANON(1) page β€” this is myanon 0.8, dated 2026-02-05, and yes, it ate. mwah πŸ’‹

πŸ“¦ where this page comes from