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

  1. 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)
  2. Upgrade Mycat to a version supporting the command, or use a driver/tool that only uses basic COM_QUERY/COM_PING against Mycat
  3. 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

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)