MyCATApache/Mycat-Server · error
ER_UNKNOWN_COM_ERROR
ER_UNKNOWN_COM_ERROR
Error message
"Unknown command"
What it means
The frontend protocol handler dispatches MySQL client commands by the packet's command byte. When the byte is not a command Mycat implements (and ignoreUnknownCommand != 1), it replies with an ERR packet (ER_UNKNOWN_COM_ERROR, "Unknown command").
Solutions
- Set <system><property name="ignoreUnknownCommand">1</property></system> in server.xml so unknown commands are answered with a ping instead of an error (for compatible tools)
- Upgrade Mycat to a version supporting the command, or use a driver/tool that only uses basic COM_QUERY/COM_PING against Mycat
- Disable pooler features like connection reset/change-user on Mycat connections (e.g. disable prepared statement usage or reset-on-return in the pool config)
Example fix
<!-- before: server.xml --> <system/> <!-- after --> <system> <property name="ignoreUnknownCommand">1</property> </system>
Defensive patterns
Strategy: try-catch
Try / catch
try { stmt.execute(sql); } catch (SQLException e) { if (e.getErrorCode() == 1047 /* ER_UNKNOWN_COM_ERROR */) { disableUnsupportedProtocolFeatures(); } else throw e; } Prevention
- Set ignoreUnknownCommand=1 in server.xml for tools sending exotic COM_ packets
- Use drivers/clients that stick to COM_QUERY/COM_PING against Mycat
- Disable pooler reset/change-user and replication features on Mycat connections
- Test new drivers and proxy tools against Mycat before rollout
When it happens
Trigger: Client sends a COM_* packet Mycat doesn't support (e.g. COM_CHANGE_USER, COM_RESET_CONNECTION, COM_BINLOG_DUMP, COM_STMT_* prepared-protocol variants) or a corrupted packet whose bytes land in the unhandled default branch of handle().
Common situations: Drivers/tools using prepared-statement or replication protocols unsupported by the Mycat version; connection poolers issuing COM_RESET_CONNECTION between checkouts; proxy tools sending COM_CHANGE_USER to re-authenticate.
Understand the failure class
Background: UnsupportedOperationException and "is not supported" errors: when a library deliberately refuses a call — this error's family across 30 libraries.
Related errors
AI-assisted analysis of MyCATApache/Mycat-Server@65f8d8beb7 (2026-09-11).
Data as JSON: /api/errors/b1ed8ef9c4cbe327.
Report an issue: GitHub.
Appendix: source
Thrown at src/main/java/io/mycat/net/handler/FrontendCommandHandler.java:131
break;
case MySQLPacket.COM_FIELD_LIST:
source.fieldList(data);
break;
case MySQLPacket.COM_SET_OPTION:
commands.doSetOption();
source.setOption(data);
break;
case MySQLPacket.COM_RESET_CONNECTION:
source.resetConnection();
break;
default:
commands.doOther();
MycatConfig config = MycatServer.getInstance().getConfig();
if( config.getSystem().getIgnoreUnknownCommand()==1){
LOGGER.warn("Unknown command:{}",data[4]);
source.ping();
}else {
LOGGER.error("Unknown command:{}",new String(data));
source.writeErrMessage(ErrorCode.ER_UNKNOWN_COM_ERROR,
"Unknown command");
}
}
}
}View on GitHub (pinned to 65f8d8beb7)