pt-fingerprint是Percona Toolkit工具集的其中一个,可以将SQL语句格式化为抽象化形式,可以用于数据脱敏等场景,接下来我们看一下。
(1)基本语法
pt-fingerprint [OPTIONS] [FILES]
(2)常见选项
--match-embedded-numbers:例如,把catch22替换为?,而不是默认地把catch22替换为catch?
--match-md5-checksums:例如,把fbc5e685a5d3d45aa1d0347fdb7c4d35替换为?,而不是默认地把fbc5e685a5d3d45aa1d0347fdb7c4d35替换为fbc?
--query:把单个SQL语句格式化为抽象化形式
(1)单个SQL语句格式化
$ pt-fingerprint --query "select a, b, c from users where id = 500"
select a, b, c from users where id = ?
(2)SQL文件格式化
$ pt-fingerprint pt-fingerprint.txt
select name, password from user where id=?
select name, password from user where id=?
pt-fingerprint这个工具,用得并不算多,但是对于慢日志/审计日志的数据脱敏,还是有很大帮助的
原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。
如有侵权,请联系 cloudcommunity@tencent.com 删除。
原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。
如有侵权,请联系 cloudcommunity@tencent.com 删除。