Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 12 additions & 3 deletions internal/cmdutil/cmdutil.go
Original file line number Diff line number Diff line change
Expand Up @@ -219,13 +219,22 @@ func MySQLClientPath() (string, mysql.AuthMethodDescription, error) {
return "", authMethod, fmt.Errorf("failed to run 'mysql --version': %w", err)
}

v := versionRegex.FindStringSubmatch(string(out))
outStr := string(out)

// Handle MariaDB clients gracefully
if strings.Contains(outStr, "MariaDB") {
// MariaDB clients use mysql_native_password by default
// https://mariadb.com/docs/server/reference/plugins/authentication-plugins/authentication-plugin-mysql_native_password
return path, mysql.MysqlNativePassword, nil
}

v := versionRegex.FindStringSubmatch(outStr)
if len(v) != 4 {
return "", authMethod, fmt.Errorf("could not parse server version from: %s", string(out))
return "", authMethod, fmt.Errorf("could not parse server version from: %s", outStr)
}
major, err := strconv.Atoi(v[1])
if err != nil {
return "", authMethod, fmt.Errorf("could not parse server version from: %s", string(out))
return "", authMethod, fmt.Errorf("could not parse server version from: %s", outStr)
}

if major < 8 {
Expand Down