mirror of
				https://gitee.com/gitea/gitea
				synced 2025-11-04 08:30:25 +08:00 
			
		
		
		
	Add mysql unix socket support.
If the host setting looks like a unix socket (leading by char '/'), will use unix(host) as connection string
This commit is contained in:
		@@ -89,8 +89,13 @@ func getEngine() (*xorm.Engine, error) {
 | 
			
		||||
	cnnstr := ""
 | 
			
		||||
	switch DbCfg.Type {
 | 
			
		||||
	case "mysql":
 | 
			
		||||
		if DbCfg.Host[0] == '/' { // looks like a unix socket
 | 
			
		||||
			cnnstr = fmt.Sprintf("%s:%s@unix(%s)/%s?charset=utf8",
 | 
			
		||||
				DbCfg.User, DbCfg.Passwd, DbCfg.Host, DbCfg.Name)
 | 
			
		||||
		} else {
 | 
			
		||||
			cnnstr = fmt.Sprintf("%s:%s@tcp(%s)/%s?charset=utf8",
 | 
			
		||||
				DbCfg.User, DbCfg.Passwd, DbCfg.Host, DbCfg.Name)
 | 
			
		||||
		}
 | 
			
		||||
	case "postgres":
 | 
			
		||||
		var host, port = "127.0.0.1", "5432"
 | 
			
		||||
		fields := strings.Split(DbCfg.Host, ":")
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user