You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
mysql -h$archery_host -P$archery_port -u$archery_user -p$archery_pw$archery_db -N -e "select
24
+
id,instance_name,host,port
25
+
from sql_instance where type='slave';">instances.list
26
+
27
+
# 清空表
28
+
mysql -h$archery_host -P$archery_port -u$archery_user -p$archery_pw$archery_db -N -e "truncate table data_masking_columns;"
29
+
30
+
# 临时账号密码(因实例账号&密码为加密,写死使用)
31
+
# 此方式只适用单个实例或多个实例账号密码一致
32
+
user=
33
+
pw=
34
+
35
+
# 获取脱敏字段信息
36
+
cat instances.list|while read instance_name host port
37
+
do
38
+
mysql -h$host -P$port -u$user -p$pw -N -e "
39
+
SELECT CASE
40
+
WHEN COLUMN_NAME REGEXP '$masking_rule_phone'
41
+
THEN 1
42
+
WHEN COLUMN_NAME REGEXP '$masking_rule_idno'
43
+
THEN 2
44
+
WHEN COLUMN_NAME REGEXP '$masking_rule_bankcardno'
45
+
THEN 3
46
+
WHEN COLUMN_NAME REGEXP '$masking_rule_mail'
47
+
THEN 4
48
+
WHEN COLUMN_NAME REGEXP '$masking_rule_amount'
49
+
THEN 5
50
+
WHEN COLUMN_NAME REGEXP '$masking_rule_others'
51
+
THEN 6
52
+
END AS rule_type,
53
+
1 AS active,
54
+
'$instance_id' instance_id,
55
+
TABLE_SCHEMA table_schema,
56
+
TABLE_NAME table_name,
57
+
COLUMN_NAME column_name,
58
+
COLUMN_COMMENT column_comment
59
+
FROM information_schema.COLUMNS
60
+
WHERE COLUMN_NAME REGEXP '$masking_rules'
61
+
AND TABLE_SCHEMA != 'performance_schema'
62
+
AND TABLE_SCHEMA != 'information_schema';">$instance_name.txt
63
+
64
+
# 更新表数据
65
+
mysql -h$archery_host -P$archery_port -u$archery_user -p$archery_pw$archery_db -N -e "load data local infile '$instance_name.txt' replace into table data_masking_columns fields terminated by '\t' ( rule_type,active,instance_id,table_schema,table_name,column_name,column_comment);"
0 commit comments