Skip to content

Database governance built for humans and agents — controlling changes and access across every major database.

chore: surpress mysqlbinlog insecure password warning (#2895)

Danny Xu49b6062606a3
diff --git a/plugin/db/mysql/restore.go b/plugin/db/mysql/restore.go
index 723513b797..639c6c425e 100644
--- a/plugin/db/mysql/restore.go
+++ b/plugin/db/mysql/restore.go
@@ -704,11 +704,13 @@ func (driver *Driver) downloadBinlogFile(ctx context.Context, binlogFileToDownlo
if driver.connCfg.Port != "" {
args = append(args, "--port", driver.connCfg.Port)
}
- if driver.connCfg.Password != "" {
- args = append(args, fmt.Sprintf("--password=%s", driver.connCfg.Password))
- }
cmd := exec.CommandContext(ctx, mysqlutil.GetPath(mysqlutil.MySQLBinlog, driver.resourceDir), args...)
+ // We cannot set password as a flag. Otherwise, there is warning message
+ // "mysqlbinlog: [Warning] Using a password on the command line interface can be insecure."
+ if driver.connCfg.Password != "" {
+ cmd.Env = append(cmd.Env, fmt.Sprintf("MYSQL_PWD=%s", driver.connCfg.Password))
+ }
cmd.Stdout = os.Stderr
cmd.Stderr = os.Stderr