MyCATApache/Mycat-Server · error · ConfigException

The specified MySQL Version

Error message

The specified MySQL Version (${version}) is not valid.

What it means

loadSystem reads the fakeMySQLVersion property from server.xml's <system> section and validates it against Versions. If validVersion is false — the string does not match a MySQL version pattern MyCat accepts — it throws this ConfigException because the version string is advertised to clients during the MySQL handshake and must look like a real MySQL version.

Solutions

  1. Set fakeMySQLVersion to a standard MySQL version string supported by your MyCat build (e.g., 5.6.29 or 5.7.18) in server.xml
  2. Check which versions Versions.checkVersion supports for your MyCat release; 8.x values may be rejected on older builds — upgrade MyCat if you must advertise 8.x
  3. Remove typos/extra suffixes so the value matches N.N.N format
  4. Restart MyCat after correcting the property

Example fix

// before (server.xml)
<property name="fakeMySQLVersion">8.0.30-custom</property>
// after
<property name="fakeMySQLVersion">5.7.18</property>
Defensive patterns

Strategy: validation

Validate before calling

// validate fakeMySQLVersion format before deploy
String v = props.getProperty("fakeMySQLVersion");
if (v == null || !v.matches("^\\d+\.\\d+\.\\d+$"))
    throw new IllegalStateException("fakeMySQLVersion must look like N.N.N, got: " + v);

Type guard

null

Try / catch

try {
    serverLoader.load();
} catch (ConfigException e) {
    LOG.error("Invalid fakeMySQLVersion: " + e.getMessage());
    throw new ConfigurationException("Use a supported MySQL version string (e.g., 5.7.18)", e);
}

Prevention

When it happens

Trigger: server.xml <system><property name="fakeMySQLVersion">5.7.99-unsupported</property></system> with a value failing version validation; property set to a non-numeric or empty string.

Common situations: Upgrading MySQL and setting fakeMySQLVersion to a version string MyCat's validator doesn't recognize (e.g., 8.x on an old MyCat); typos like '5..7' or 'v5.7'; leaving a placeholder value in the property.

Understand the failure class

Background: "Invalid value" and "allowed values are" config errors: what your library rejected and how to fix it — this error's family across 41 libraries.

Related errors


AI-assisted analysis of MyCATApache/Mycat-Server@65f8d8beb7 (2026-09-11). Data as JSON: /api/errors/d90fd1d3178cb382. Report an issue: GitHub.

Appendix: source

Thrown at src/main/java/io/mycat/config/loader/xml/XMLServerLoader.java:360

        if (system.getFakeMySQLVersion() != null) {
            boolean validVersion = true;
            String majorMySQLVersion = system.getFakeMySQLVersion();
            /*
             * 注意!!! 目前MySQL官方主版本号仍然是5.x, 以后万一前面的大版本号变成2位数字,
             * 比如 10.x...,下面获取主版本的代码要做修改
             */
//            majorMySQLVersion = majorMySQLVersion.substring(0, majorMySQLVersion.indexOf(".", 2));
//            for (String ver : SystemConfig.MySQLVersions) {
//                // 这里只是比较mysql前面的大版本号
//                if (majorMySQLVersion.equals(ver)) {
//                    validVersion = true;
//                }
//            }

            if (validVersion) {
                Versions.setServerVersion(system.getFakeMySQLVersion());
            } else {
                throw new ConfigException("The specified MySQL Version (" + system.getFakeMySQLVersion()
                        + ") is not valid.");
            }
        }
    }

}

View on GitHub (pinned to 65f8d8beb7)