@@ -41,11 +41,6 @@ func MySQLCheck() {
4141
4242 output := strings .TrimSpace (string (out ))
4343
44- // Extract semantic version like 8.0.37 or 10.11.6 from mixed outputs
45- versionRegex := regexp .MustCompile (`\b(\d+\.\d+(?:\.\d+)?)\b` )
46- versionMatch := versionRegex .FindString (output )
47-
48- // Determine flavor for naming and storage key
4944 isMaria := strings .Contains (strings .ToLower (output ), "mariadb" ) || serverBinary == "mariadbd" || serverBinary == "mariadb"
5045 serviceKey := "mysql"
5146 serviceTitle := "MySQL"
@@ -54,13 +49,30 @@ func MySQLCheck() {
5449 serviceTitle = "MariaDB"
5550 }
5651
52+ var versionMatch string
53+
54+ if serverBinary == "mysql" || serverBinary == "mariadb" {
55+ if isMaria {
56+ fromRegex := regexp .MustCompile (`from\s+([^\s,\-]+)` )
57+ if matches := fromRegex .FindStringSubmatch (output ); len (matches ) > 1 {
58+ versionMatch = matches [1 ]
59+ }
60+ } else {
61+ distribRegex := regexp .MustCompile (`Distrib\s+([^\s,]+)` )
62+ if matches := distribRegex .FindStringSubmatch (output ); len (matches ) > 1 {
63+ versionMatch = matches [1 ]
64+ }
65+ }
66+ } else {
67+ versionRegex := regexp .MustCompile (`\b(\d+\.\d+(?:\.\d+)?)\b` )
68+ versionMatch = versionRegex .FindString (output )
69+ }
70+
5771 if versionMatch == "" {
58- // As a fallback, try token after "Ver" if present
5972 fields := strings .Fields (output )
6073 for i := 0 ; i < len (fields )- 1 ; i ++ {
6174 if strings .EqualFold (fields [i ], "Ver" ) {
6275 candidate := strings .Trim (fields [i + 1 ], "," )
63- // Strip distro suffixes like -0ubuntu...
6476 if idx := strings .Index (candidate , "-" ); idx > 0 {
6577 candidate = candidate [:idx ]
6678 }
@@ -70,6 +82,11 @@ func MySQLCheck() {
7082 }
7183 }
7284
85+ if versionMatch == "" {
86+ versionRegex := regexp .MustCompile (`\b(\d+\.\d+(?:\.\d+)?)\b` )
87+ versionMatch = versionRegex .FindString (output )
88+ }
89+
7390 if versionMatch == "" {
7491 log .Error ().Str ("output" , output ).Msg ("Unable to parse MySQL/MariaDB version" )
7592 addToVersionErrors (fmt .Errorf ("Unable to parse MySQL/MariaDB version" ))
0 commit comments