diff --git a/dbm-services/mysql/db-tools/dbactuator/pkg/components/spiderctl/import_schema_from_backend.go b/dbm-services/mysql/db-tools/dbactuator/pkg/components/spiderctl/import_schema_from_backend.go index 90baebd243..7bbcca2c28 100644 --- a/dbm-services/mysql/db-tools/dbactuator/pkg/components/spiderctl/import_schema_from_backend.go +++ b/dbm-services/mysql/db-tools/dbactuator/pkg/components/spiderctl/import_schema_from_backend.go @@ -279,6 +279,7 @@ func (c *ImportSchemaFromBackendComp) migrateUseMydumper() (err error) { } // migrateUseMysqlDump 运行备份表结构 +// nolint func (c *ImportSchemaFromBackendComp) migrateUseMysqlDump() (err error) { dumpOption := mysqlutil.MySQLDumpOption{ DumpSchema: true, @@ -306,11 +307,21 @@ func (c *ImportSchemaFromBackendComp) migrateUseMysqlDump() (err error) { Charset: c.charset, MySQLDumpOption: dumpOption, } - if err := dumper.Dump(); err != nil { + if err = dumper.Dump(); err != nil { logger.Error("dump failed: %s", err.Error()) return err } logger.Info("备份表结构成功,开始导入表结构到中控") + _, err = c.tdbctlConn.Exec("set global tc_admin=0;") + if err != nil { + return err + } + defer func() { + _, err = c.tdbctlConn.Exec("set global tc_admin=1;") + if err != nil { + logger.Error("set global tc_admin=1 failed %s,请手动配置成tc_admin = 1", err.Error()) + } + }() dumpfileInfo := dumper.GetDumpFileInfo() loader := mysqlutil.ExecuteSqlAtLocal{ IsForce: false, diff --git a/dbm-services/mysql/db-tools/dbactuator/pkg/util/mysqlutil/mysqlclient_exec.go b/dbm-services/mysql/db-tools/dbactuator/pkg/util/mysqlutil/mysqlclient_exec.go index a97f17c8dc..f156b5662b 100644 --- a/dbm-services/mysql/db-tools/dbactuator/pkg/util/mysqlutil/mysqlclient_exec.go +++ b/dbm-services/mysql/db-tools/dbactuator/pkg/util/mysqlutil/mysqlclient_exec.go @@ -88,6 +88,7 @@ func (e ExecuteSqlAtLocal) ExecuteSqlByMySQLClient(sqlfile string, targetdbs []s return nil } +// ExecuteSqlWithOutReport TODO func (e ExecuteSqlAtLocal) ExecuteSqlWithOutReport(sqlfile string, targetdbs []string) (err error) { for _, db := range targetdbs { if err = e.ExecuteSqlByMySQLClientOne(sqlfile, db, false); err != nil { @@ -114,6 +115,7 @@ func (e ExecuteSqlAtLocal) ExecuteSqlByMySQLClientOne(sqlfile string, db string, return nil } +// TestConnectionByMySQLClient TODO func (e ExecuteSqlAtLocal) TestConnectionByMySQLClient(db string, report bool) (err error) { command := e.CreateLoadSQLCommand() command = fmt.Sprintf(`echo "select version()" | %s %s`, command, db) @@ -144,7 +146,7 @@ func (e ExecuteSqlAtLocal) ExecuteCommand(command string, report bool) (err erro defer ef.Sync() // 标准输出复制一份到错误文件中 stdout := io.MultiWriter(os.Stdout) - //stdout := io.MultiWriter(os.Stdout, ef) + // stdout := io.MultiWriter(os.Stdout, ef) // 错误不输出控制台 去掉os.Stderr // stderr := io.MultiWriter(os.Stderr, &stderrBuf, ef) stderr := io.MultiWriter(&stderrBuf, ef)