安装时检测本地数据库时增加更多的候选密码

This commit is contained in:
GoEdgeLab
2022-11-18 17:07:12 +08:00
parent e8ef7185b8
commit 34bdee27f6

View File

@@ -8,6 +8,7 @@ import (
"github.com/iwind/TeaGo/dbs" "github.com/iwind/TeaGo/dbs"
"github.com/iwind/TeaGo/maps" "github.com/iwind/TeaGo/maps"
"net" "net"
"os"
"strings" "strings"
"time" "time"
) )
@@ -31,7 +32,18 @@ func (this *DetectDBAction) RunPost(params struct{}) {
localPort = "3306" localPort = "3306"
var username = "root" var username = "root"
for _, pass := range []string{"", "123456", "654321", "Aa_123456"} { var passwords = []string{"", "123456", "654321", "Aa_123456", "111111"}
// 使用 foolish-mysql 安装的MySQL
localGeneratedPasswordData, err := os.ReadFile("/usr/local/mysql/generated-password.txt")
if err == nil {
var localGeneratedPassword = strings.TrimSpace(string(localGeneratedPasswordData))
if len(localGeneratedPassword) > 0 {
passwords = append(passwords, localGeneratedPassword)
}
}
for _, pass := range passwords {
db, err := dbs.NewInstanceFromConfig(&dbs.DBConfig{ db, err := dbs.NewInstanceFromConfig(&dbs.DBConfig{
Driver: "mysql", Driver: "mysql",
Dsn: username + ":" + pass + "@tcp(" + configutils.QuoteIP(localHost) + ":" + localPort + ")/edges", Dsn: username + ":" + pass + "@tcp(" + configutils.QuoteIP(localHost) + ":" + localPort + ")/edges",