{"record":{"id":"5dd333b31019d02f","repo":"alibaba/canal","slug":"command-show-variables-like-server-id-has-an-e","errorCode":null,"errorMessage":"command : show variables like 'server_id' has an error! pls check. you need (at least one of) the SUPER,REPLICATION CLIENT privilege(s) for this operation","messagePattern":"command : show variables like 'server_id' has an error! pls check\\. you need \\(at least one of\\) the SUPER,REPLICATION CLIENT privilege\\(s\\) for this operation","errorType":"exception","errorClass":"CanalParseException","httpStatus":null,"severity":"error","filePath":"parse/src/main/java/com/alibaba/otter/canal/parse/inbound/mysql/MysqlEventParser.java","lineNumber":655,"sourceCode":"                        startSearchBinlogFile.indexOf(\".\") + 1);\n                    String binlogFileNameSuffix = String.format(\"%06d\", nextBinlogSeqNum);\n                    startSearchBinlogFile = binlogFileNamePrefix + binlogFileNameSuffix;\n                }\n            }\n        }\n        // 找不到\n        return null;\n    }\n\n    /**\n     * 查询当前db的serverId信息\n     */\n    private Long findServerId(MysqlConnection mysqlConnection) {\n        try {\n            ResultSetPacket packet = mysqlConnection.query(\"show variables like 'server_id'\");\n            List<String> fields = packet.getFieldValues();\n            if (CollectionUtils.isEmpty(fields)) {\n                throw new CanalParseException(\"command : show variables like 'server_id' has an error! pls check. you need (at least one of) the SUPER,REPLICATION CLIENT privilege(s) for this operation\");\n            }\n            return Long.valueOf(fields.get(1));\n        } catch (IOException e) {\n            throw new CanalParseException(\"command : show variables like 'server_id' has an error!\", e);\n        }\n    }\n\n    /**\n     * 查询当前的binlog位置\n     */\n    private EntryPosition findEndPosition(MysqlConnection mysqlConnection) {\n        String showSql = \"show master status\";\n        try {\n            if (mysqlConnection.atLeastMySQL84()) {\n                // 8.4新语法\n                showSql = \"show binary log status\";\n            } else if (multiStreamEnable) {\n                // 兼容polardb-x的多流binlog","sourceCodeStart":637,"sourceCodeEnd":673,"githubUrl":"https://github.com/alibaba/canal/blob/87be50e87686a3e8af08c368d0e1ffd1f59eb04a/parse/src/main/java/com/alibaba/otter/canal/parse/inbound/mysql/MysqlEventParser.java#L637-L673","documentation":"findServerId() queries `show variables like 'server_id'`; if the result field list is empty, Canal assumes the account lacks the privilege to read the variable and throws CanalParseException instructing the operator to grant SUPER / REPLICATION CLIENT. An empty result set here almost always means the session cannot see the variable.","triggerScenarios":"The canal DB user runs `show variables like 'server_id'` and gets no rows — the variable is hidden because the account lacks PROCESS/SUPER/REPLICATION CLIENT privileges, or the server is configured to restrict variable visibility.","commonSituations":"Fresh canal setup where the DB user was granted only minimal privileges; connecting to a hardened/cloud MySQL where variable access is restricted; the user was created without REPLICATION CLIENT.","solutions":["Grant privileges: `GRANT SELECT, REPLICATION SLAVE, REPLICATION CLIENT ON *.* TO 'canal'@'%';` (add SUPER if your MySQL version requires it for variables).","Verify as the canal user: `SHOW VARIABLES LIKE 'server_id';` returns a row.","On MySQL 8.x, ensure the account has PROCESS privilege if variable visibility is restricted."],"exampleFix":"GRANT SELECT, REPLICATION SLAVE, REPLICATION CLIENT, SUPER ON *.* TO 'canal'@'%';\nFLUSH PRIVILEGES;","handlingStrategy":"validation","validationCode":"// Pre-flight: confirm the user can read server_id\nResultSetPacket rs = connection.query(\"show variables like 'server_id'\");\nif (rs == null || CollectionUtils.isEmpty(rs.getFieldValues())) {\n    throw new IllegalStateException(\"Cannot read server_id; grant REPLICATION CLIENT/SUPER to the canal user.\");\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Grant REPLICATION CLIENT and (on some MySQL versions) SUPER/PROCESS to the canal account.","Pre-flight variable queries as the canal user during deployment.","Test the privilege set after any DB migration."],"tags":["mysql","privilege","server-id","metadata-query","canal-parse"],"backgroundTag":null,"analyzedSha":"87be50e87686a3e8af08c368d0e1ffd1f59eb04a","analyzedAt":"2026-08-14T04:30:11.918Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}