mirror of
https://github.com/1Panel-dev/1Panel.git
synced 2025-01-31 22:18:07 +08:00
fix: 数据库创建重名用户问题修改 (#887)
This commit is contained in:
parent
a184cb9bc4
commit
eb50ee1c03
@ -518,12 +518,12 @@ func excSQL(containerName, password, command string) error {
|
|||||||
ctx, cancel := context.WithTimeout(context.Background(), 1*time.Second)
|
ctx, cancel := context.WithTimeout(context.Background(), 1*time.Second)
|
||||||
defer cancel()
|
defer cancel()
|
||||||
cmd := exec.CommandContext(ctx, "docker", "exec", containerName, "mysql", "-uroot", "-p"+password, "-e", command)
|
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 {
|
if ctx.Err() == context.DeadlineExceeded {
|
||||||
return buserr.WithDetail(constant.ErrExecTimeOut, containerName, nil)
|
return buserr.WithDetail(constant.ErrExecTimeOut, containerName, nil)
|
||||||
}
|
}
|
||||||
if err != nil {
|
stdStr := strings.ReplaceAll(string(stdout), "mysql: [Warning] Using a password on the command line interface can be insecure.\n", "")
|
||||||
stdStr := strings.ReplaceAll(err.Error(), "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 errors.New(stdStr)
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
|
Loading…
x
Reference in New Issue
Block a user