mirror of
				https://github.com/TeaOSLab/EdgeAdmin.git
				synced 2025-11-04 13:10:26 +08:00 
			
		
		
		
	检测本地数据库时,主机地址增加尝试localhost、172.20.0.2
This commit is contained in:
		@@ -26,10 +26,11 @@ func (this *DetectDBAction) RunPost(params struct{}) {
 | 
				
			|||||||
	var localPassword = ""
 | 
						var localPassword = ""
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	// 本地的3306端口是否可以连接
 | 
						// 本地的3306端口是否可以连接
 | 
				
			||||||
	conn, err := net.DialTimeout("tcp", "127.0.0.1:3306", 3*time.Second)
 | 
						for _, tryingHost := range []string{"127.0.0.1", "localhost", "172.20.0.2"} {
 | 
				
			||||||
	if err == nil {
 | 
							conn, dialErr := net.DialTimeout("tcp", tryingHost+":3306", 3*time.Second)
 | 
				
			||||||
 | 
							if dialErr == nil {
 | 
				
			||||||
			_ = conn.Close()
 | 
								_ = conn.Close()
 | 
				
			||||||
		localHost = "127.0.0.1"
 | 
								localHost = tryingHost
 | 
				
			||||||
			localPort = "3306"
 | 
								localPort = "3306"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
			var username = "root"
 | 
								var username = "root"
 | 
				
			||||||
@@ -61,6 +62,9 @@ func (this *DetectDBAction) RunPost(params struct{}) {
 | 
				
			|||||||
					}
 | 
										}
 | 
				
			||||||
				}
 | 
									}
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
								break
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	this.Data["localDB"] = maps.Map{
 | 
						this.Data["localDB"] = maps.Map{
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user