修复使用localhost连接数据库时不能自动尝试启动的问题

This commit is contained in:
GoEdgeLab
2023-05-20 16:58:14 +08:00
parent be0874dc37
commit 5c770e76e5

View File

@@ -309,7 +309,7 @@ func (this *APINode) checkDB() error {
// 决定是否尝试启动本地的MySQL
if strings.Contains(err.Error(), "connection refused") {
config, _ := db.Config()
if config != nil && (strings.Contains(config.Dsn, "tcp(127.0.0.1:") || strings.Contains(config.Dsn, "tcp(localhost:)")) && os.Getgid() == 0 /** ROOT 用户 **/ {
if config != nil && (strings.Contains(config.Dsn, "tcp(127.0.0.1:") || strings.Contains(config.Dsn, "tcp(localhost:")) && os.Getgid() == 0 /** ROOT 用户 **/ {
var mysqldSafeFile = "/usr/local/mysql/bin/mysqld_safe"
_, err = os.Stat(mysqldSafeFile)
if err == nil {