From 5efcf7f2cb84b6b737a4a08ede92a809f7d9d0a8 Mon Sep 17 00:00:00 2001 From: elonzh Date: Tue, 10 Aug 2021 20:31:07 +0800 Subject: [PATCH] hidden mysql password in log --- dump/dumper.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/dump/dumper.go b/dump/dumper.go index fdd250c5c..038624885 100644 --- a/dump/dumper.go +++ b/dump/dumper.go @@ -164,7 +164,9 @@ func (d *Dumper) Dump(w io.Writer) error { } args = append(args, fmt.Sprintf("--user=%s", d.User)) - args = append(args, fmt.Sprintf("--password=%s", d.Password)) + passwordArg := fmt.Sprintf("--password=%s", d.Password) + args = append(args, passwordArg) + passwordArgIndex := len(args) - 1 if !d.masterDataSkipped { args = append(args, "--master-data") @@ -238,7 +240,9 @@ func (d *Dumper) Dump(w io.Writer) error { } } + args[passwordArgIndex] = "--password=******" log.Infof("exec mysqldump with %v", args) + args[passwordArgIndex] = passwordArg cmd := exec.Command(d.ExecutionPath, args...) cmd.Stderr = d.ErrOut