Database governance built for humans and agents — controlling changes and access across every major database.
Go cicddata-governancedata-maskingdata-securitydatabase-accessdatabase-governancedevopsdevsecopsflywaygitopsliquibasemongodbmysqloraclepostgresqlschema-migrationssecuritysql-clientsqlservertidb
fix(PITR): handle mysql/mysqlbinlog --password parameter, add privileges prompts for non-root users (#1466)
Yilong Lic6920bdf43bf
diff --git a/common/log/logger.go b/common/log/logger.goindex 87061aac1a..ca0c050a8f 100644--- a/common/log/logger.go+++ b/common/log/logger.go@@ -53,8 +53,8 @@ func Warn(msg string, fields ...zap.Field) {// Error wraps the zap Logger's Error method.func Error(msg string, fields ...zap.Field) {// Append the stack info in Error logging for better debugging experience.- // Note that we should skip 2 stack frames so that the top frame start at the caller of log.Error.- fields = append(fields, zap.StackSkip("stack", 2))+ // Note that we should skip one stack frames so that the top frame start at the caller of log.Error.+ fields = append(fields, zap.StackSkip("stack", 1))gl.Error(msg, fields...)}diff --git a/frontend/src/components/CreateDataSourceExample.vue b/frontend/src/components/CreateDataSourceExample.vueindex d140a2c786..8b0c7cb630 100644--- a/frontend/src/components/CreateDataSourceExample.vue+++ b/frontend/src/components/CreateDataSourceExample.vue@@ -159,7 +159,7 @@ const grantStatement = (switch (engineType) {case "MYSQL":case "TIDB":- return "CREATE USER bytebase@'%' IDENTIFIED BY 'YOUR_DB_PWD';\n\nGRANT ALTER, ALTER ROUTINE, CREATE, CREATE ROUTINE, CREATE VIEW, \nDELETE, DROP, EVENT, EXECUTE, INDEX, INSERT, PROCESS, REFERENCES, \nSELECT, SHOW DATABASES, SHOW VIEW, TRIGGER, UPDATE, USAGE \nON *.* to bytebase@'%';";+ return "CREATE USER bytebase@'%' IDENTIFIED BY 'YOUR_DB_PWD';\n\nGRANT ALTER, ALTER ROUTINE, CREATE, CREATE ROUTINE, CREATE VIEW, \nDELETE, DROP, EVENT, EXECUTE, INDEX, INSERT, PROCESS, REFERENCES, \nSELECT, SHOW DATABASES, SHOW VIEW, TRIGGER, UPDATE, USAGE, \nFLUSH_TABLES, LOCK TABLES, REPLICATION CLIENT, REPLICATION SLAVE, \nREPLICATION_APPLIER, SESSION_VARIABLES_ADMIN \nON *.* to bytebase@'%';";case "CLICKHOUSE":return "CREATE USER bytebase IDENTIFIED BY 'YOUR_DB_PWD';\n\nGRANT ALL ON *.* TO bytebase WITH GRANT OPTION;";case "SNOWFLAKE":diff --git a/plugin/restore/mysql/mysql.go b/plugin/restore/mysql/mysql.goindex a498702039..cb4a8ce499 100644--- a/plugin/restore/mysql/mysql.go+++ b/plugin/restore/mysql/mysql.go@@ -90,7 +90,9 @@ func (r *Restore) replayBinlog(ctx context.Context, originalDatabase, pitrDatabamysqlArgs = append(mysqlArgs, "--port", r.connCfg.Port)}if r.connCfg.Password != "" {- mysqlArgs = append(mysqlArgs, "--password", r.connCfg.Password)+ // The --password parameter of mysql/mysqlbinlog does not support the "--password PASSWORD" format (split by space).+ // If provided like that, the program will hang.+ mysqlArgs = append(mysqlArgs, fmt.Sprintf("--password=%s", r.connCfg.Password))}mysqlbinlogCmd := exec.CommandContext(ctx, r.mysqlutil.GetPath(mysqlutil.MySQLBinlog), mysqlbinlogArgs...)@@ -523,7 +525,7 @@ func (r *Restore) downloadBinlogFile(ctx context.Context, binlog mysql.BinlogFilargs = append(args, "--port", r.connCfg.Port)}if r.connCfg.Password != "" {- args = append(args, "--password", r.connCfg.Password)+ args = append(args, fmt.Sprintf("--password=%s", r.connCfg.Password))}cmd := exec.CommandContext(ctx, r.mysqlutil.GetPath(mysqlutil.MySQLBinlog), args...)@@ -537,6 +539,7 @@ func (r *Restore) downloadBinlogFile(ctx context.Context, binlog mysql.BinlogFilreturn fmt.Errorf("mysqlbinlog fails, error: %w", err)}+ log.Debug("Checking binlog file stat", zap.String("path", resultFilePath))fileInfo, err := os.Stat(resultFilePath)if err != nil {_ = os.Remove(resultFilePath)diff --git a/resources/mysqlutil/mysqlutil.go b/resources/mysqlutil/mysqlutil.goindex dab0bf922f..0300c9b952 100644--- a/resources/mysqlutil/mysqlutil.go+++ b/resources/mysqlutil/mysqlutil.go@@ -49,7 +49,7 @@ func (ins *Instance) Version(binName binaryName) (string, error) {case MySQLBinlog:cmd = exec.Command(ins.GetPath(MySQLBinlog), "-V")default:- return "", fmt.Errorf("Unknown binary name: %s", binName)+ return "", fmt.Errorf("unknown binary name: %s", binName)}cmd.Stdout = &version@@ -71,7 +71,7 @@ func Install(resourceDir string) (*Instance, error) {case runtime.GOOS == "linux" && runtime.GOARCH == "amd64":tarName = "mysqlutil-8.0.28-linux-glibc2.17-x86_64.tar.gz"default:- return nil, fmt.Errorf("Unsupported combination of OS[%s] and ARCH[%s]", runtime.GOOS, runtime.GOARCH)+ return nil, fmt.Errorf("unsupported combination of OS[%s] and ARCH[%s]", runtime.GOOS, runtime.GOARCH)}version := strings.TrimRight(tarName, "tar.gz")diff --git a/server/task_check_scheduler.go b/server/task_check_scheduler.goindex 06c9d139a3..e1537fe737 100644--- a/server/task_check_scheduler.go+++ b/server/task_check_scheduler.go@@ -121,7 +121,7 @@ func (s *TaskCheckScheduler) Run(ctx context.Context, wg *sync.WaitGroup) {)}} else {- log.Debug("Failed to run task check",+ log.Warn("Failed to run task check",zap.Int("id", taskCheckRun.ID),zap.Int("task_id", taskCheckRun.TaskID),zap.String("type", string(taskCheckRun.Type)),diff --git a/server/task_scheduler.go b/server/task_scheduler.goindex bbaa83e0b9..4d3005bf45 100644--- a/server/task_scheduler.go+++ b/server/task_scheduler.go@@ -171,7 +171,7 @@ func (s *TaskScheduler) Run(ctx context.Context, wg *sync.WaitGroup) {)}} else {- log.Debug("Failed to run task",+ log.Warn("Failed to run task",zap.Int("id", task.ID),zap.String("name", task.Name),zap.String("type", string(task.Type)),