MyCATApache/Mycat-Server · error · SQLSyntaxErrorException
not found schema :
Error message
not found schema :
What it means
While analysing a SHOW statement (analyseShowSQL, e.g. SHOW FULL COLUMNS from an information_schema query), Mycat extracts the related schema name from the SQL fields and looks it up in the server's schema config; if that schema is not defined in Mycat's configuration, it throws 'not found schema : <name>'.
Solutions
- Add the missing schema to schema.xml (with at least one table/datanode) and restart/reload Mycat config.
- Connect the client to a schema name that is defined in Mycat's configuration.
- Fix case/typo mismatches between the SQL's schema reference and the configured schema name.
- Filter or configure the client tool to only introspect configured schemas.
Example fix
// before (schema.xml) <schema name="db1" ...>...</schema> // after (add the schema the client references) <schema name="db2" dataNode="dn1">...</schema>
Defensive patterns
Strategy: try-catch
Validate before calling
// check the referenced schema exists in Mycat config before sending SHOW
SchemaConfig sc = MycatServer.getInstance().getConfig().getSchemas().get(relSchema);
if (sc == null) throw new IllegalArgumentException("Schema not configured in Mycat: " + relSchema); Try / catch
try { rrs = routeSystemInfo(showSql, sqlType, sc, ...); } catch (SQLSyntaxErrorException e) {
if (e.getMessage().startsWith("not found schema : ")) {
String missing = e.getMessage().substring("not found schema : ".length());
log.warn("Client referenced unconfigured schema {}", missing);
} else throw e;
} Prevention
- Declare every schema clients may reference in schema.xml.
- Match database-name case exactly between clients and config.
- Restrict GUI/introspection tools to configured schemas.
- Reload Mycat config after schema additions before clients connect.
When it happens
Trigger: Running SHOW statements (e.g. from clients or GUI tools like MySQL Workbench/Navicat) whose query references a schema/database name absent from Mycat's schema.xml, or where the client sends a relation schema different from the current one.
Common situations: GUI tools enumerating all databases including ones not declared in schema.xml; clients connected to a database name that was never configured; typos or case mismatches in schema names; schemas dropped from config while clients still reference them.
Understand the failure class
Background: 'Could not be found', 'does not exist', 'not found in database': the resource-not-found family when an ID, slug, key, or URI lookup comes back empty — this error's family across 20 libraries.
Related errors
- "can't find table define in schema " + tableName + "…
- can't find table define of in schema:
- ERR_HANDLE_DATA
- newSchema: is not exists!
- oldSchema: is not exists!
AI-assisted analysis of MyCATApache/Mycat-Server@65f8d8beb7 (2026-09-11).
Data as JSON: /api/errors/bef4986025fe9435.
Report an issue: GitHub.
Appendix: source
Thrown at src/main/java/io/mycat/route/impl/DruidMycatRouteStrategy.java:624
}
}
/**
* 分析 SHOW SQL
*/
@Override
public RouteResultset analyseShowSQL(SchemaConfig schema,
RouteResultset rrs, String stmt) throws SQLSyntaxErrorException {
String[] fields = SchemaUtil.parseShowTable(stmt);
if ("1".equals(fields[0])) {// show tables
String relSchema = fields[3];
String tableName = fields[8];
//
if (relSchema != null && !relSchema.equalsIgnoreCase(schema.getName())) {
schema = MycatServer.getInstance().getConfig().getSchemas().get(relSchema);
if (schema == null) {
throw new SQLSyntaxErrorException("not found schema : " + relSchema);
}
}
// 2020/03/19 Ken.Li
// if (StringUtils.isNotBlank(tableName) && tableName.indexOf("%") < 0) {
if (StringUtils.isNotBlank(tableName) && tableName.indexOf("%") < 0 && !schema.getTables().isEmpty()) {
TableConfig tableConfig = schema.getTables().get(tableName.toUpperCase());
if (tableConfig != null) {
String dataNode = RouterUtil.getAliveRandomDataNode(tableConfig);
PhysicalDBNode dataNodeObj = MycatServer.getInstance().getConfig().getDataNodes().get(dataNode);
if (StringUtils.isNotBlank(dataNodeObj.getDatabase())) {
stmt = stmt.replaceAll(relSchema, dataNodeObj.getDatabase());
}
return RouterUtil.routeToSingleNode(rrs, dataNode, stmt);
}
}
// remove db
if (StringUtils.isNotBlank(relSchema)) {
if(schema.getDataNode() !=null) {View on GitHub (pinned to 65f8d8beb7)