bytebase/bytebase · error

failed to parse MySQL version %s to semantic version

Error message

failed to parse MySQL version %s to semantic version

What it means

During schema sync, the MySQL driver reads the server version string (from getVersion, typically `SELECT VERSION()`) and converts it to a semantic version with semver.Make. If the returned string is not a parseable semantic version, the driver aborts the sync because all subsequent feature checks (8.0.x comparisons) depend on it. The original parse error is wrapped with the offending version string.

Source

Thrown at backend/plugin/db/mysql/sync.go:202

	}

	return isoBytes, nil
}

// SyncDBSchema syncs a single database schema.
func (d *Driver) SyncDBSchema(ctx context.Context) (*storepb.DatabaseSchemaMetadata, error) {
	schemaMetadata := &storepb.SchemaMetadata{
		Name: "",
	}

	// Query MySQL version
	version, rest, err := d.getVersion(ctx)
	if err != nil {
		return nil, err
	}
	semVersion, err := semver.Make(version)
	if err != nil {
		return nil, errors.Wrapf(err, "failed to parse MySQL version %s to semantic version", version)
	}
	atLeast800 := semVersion.GE(semver.MustParse("8.0.0"))
	atLeast803 := semVersion.GE(semver.MustParse("8.0.3"))
	atLeast8_0_13 := semVersion.GE(semver.MustParse("8.0.13"))
	atLeast8_0_16 := semVersion.GE(semver.MustParse("8.0.16"))
	atLeast5_7_0 := semVersion.GE(semver.MustParse("5.7.0"))
	isMariaDB := strings.Contains(rest, "MariaDB")
	// Some information_schema features exist only on stock MySQL: compatible engines
	// (MariaDB, OceanBase, TiDB) registered as MYSQL report MySQL-like versions but
	// lack them, so every stock-only query/decode must share this one predicate.
	stockMySQL := isStockMySQL(rest)
	// Binary-family (binary charset) literal defaults are reported by
	// information_schema.COLUMNS in version-specific encodings that must be decoded to
	// the canonical dump form (see canonicalBinaryDefault). The conventions are verified
	// for stock MySQL only; MariaDB, OceanBase, and TiDB keep the legacy verbatim path.
	binaryDefaultFmt := binaryDefaultVerbatim
	if stockMySQL {
		if atLeast800 {

View on GitHub (pinned to 1870550677)

Solutions

  1. Log/inspect the actual version string via `SELECT VERSION()` on the target instance to see what fails to parse.
  2. If it is MariaDB or a fork, use the proper MariaDB driver/connection path instead of the MySQL one.
  3. If a proxy rewrites the version, configure the proxy to pass through a standard MySQL version string.
  4. If the version is standard but has an extra suffix, upgrade the driver/plugin so the version normalization handles it, or patch getVersion to strip the suffix before semver.Make.

Example fix

// before
semVersion, err := semver.Make(version)
// after
v := version
if i := strings.IndexAny(v, "-"); i >= 0 { v = v[:i] }
semVersion, err := semver.Make(v)
Defensive patterns

Strategy: validation

Validate before calling

var v string
if err := db.QueryRow("SELECT VERSION()").Scan(&v); err != nil { return err }
base := strings.Fields(v)[0]
if i := strings.Index(base, "-"); i >= 0 { base = base[:i] }
if _, err := semver.Make(base); err != nil { return fmt.Errorf("unparseable server version %q", v) }

Try / catch

if err != nil {
  var semErr *semver.ParseError
  if errors.As(errors.Unwrap(err), &semErr) { /* fallback: treat as unknown version, skip 8.0-only paths */ }
}

Prevention

When it happens

Trigger: SyncDBSchema on a MySQL server whose VERSION() output cannot be parsed as a semver: non-standard version strings, forked builds, version strings with unexpected suffixes/prefixes (e.g. '5.5.5-10.1.20-MariaDB', '6.0.11-log' style oddities), or a proxy returning a custom banner.

Common situations: Pointing Bytebase at MariaDB, Percona forks with unusual versioning, MySQL-compatible proxies (ProxySQL, Vitess) that rewrite the version string, or cloud servers reporting versions with non-numeric prefixes.

Understand the failure class

Background: "Invalid ... format", "must be in format X", "does not look like a ..." — invalid argument format errors across CLI tools and libraries — this error's family across 17 libraries.

Related errors


AI-assisted analysis of bytebase/bytebase@1870550677 (2026-09-06). Data as JSON: /api/errors/c1607c494fb18112. Report an issue: GitHub.