Skip to content

Commit

Permalink
fix: 数据库创建重名用户问题修改 (#887)
Browse files Browse the repository at this point in the history
  • Loading branch information
ssongliu authored May 6, 2023
1 parent a184cb9 commit eb50ee1
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions backend/app/service/database_mysql.go
Original file line number Diff line number Diff line change
Expand Up @@ -518,12 +518,12 @@ func excSQL(containerName, password, command string) error {
ctx, cancel := context.WithTimeout(context.Background(), 1*time.Second)
defer cancel()
cmd := exec.CommandContext(ctx, "docker", "exec", containerName, "mysql", "-uroot", "-p"+password, "-e", command)
err := cmd.Run()
stdout, err := cmd.CombinedOutput()
if ctx.Err() == context.DeadlineExceeded {
return buserr.WithDetail(constant.ErrExecTimeOut, containerName, nil)
}
if err != nil {
stdStr := strings.ReplaceAll(err.Error(), "mysql: [Warning] Using a password on the command line interface can be insecure.\n", "")
stdStr := strings.ReplaceAll(string(stdout), "mysql: [Warning] Using a password on the command line interface can be insecure.\n", "")
if err != nil || strings.HasPrefix(string(stdStr), "ERROR ") {
return errors.New(stdStr)
}
return nil
Expand Down

0 comments on commit eb50ee1

Please sign in to comment.