alibaba/canal · error · CanalParseException
command : show variables like 'server_id' has an error! pls
Error message
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
What it means
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.
Source
Thrown at parse/src/main/java/com/alibaba/otter/canal/parse/inbound/mysql/MysqlEventParser.java:655
startSearchBinlogFile.indexOf(".") + 1);
String binlogFileNameSuffix = String.format("%06d", nextBinlogSeqNum);
startSearchBinlogFile = binlogFileNamePrefix + binlogFileNameSuffix;
}
}
}
// 找不到
return null;
}
/**
* 查询当前db的serverId信息
*/
private Long findServerId(MysqlConnection mysqlConnection) {
try {
ResultSetPacket packet = mysqlConnection.query("show variables like 'server_id'");
List<String> fields = packet.getFieldValues();
if (CollectionUtils.isEmpty(fields)) {
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");
}
return Long.valueOf(fields.get(1));
} catch (IOException e) {
throw new CanalParseException("command : show variables like 'server_id' has an error!", e);
}
}
/**
* 查询当前的binlog位置
*/
private EntryPosition findEndPosition(MysqlConnection mysqlConnection) {
String showSql = "show master status";
try {
if (mysqlConnection.atLeastMySQL84()) {
// 8.4新语法
showSql = "show binary log status";
} else if (multiStreamEnable) {
// 兼容polardb-x的多流binlogView on GitHub (pinned to 87be50e876)
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.
Example fix
GRANT SELECT, REPLICATION SLAVE, REPLICATION CLIENT, SUPER ON *.* TO 'canal'@'%'; FLUSH PRIVILEGES;
Defensive patterns
Strategy: validation
Validate before calling
// Pre-flight: confirm the user can read server_id
ResultSetPacket rs = connection.query("show variables like 'server_id'");
if (rs == null || CollectionUtils.isEmpty(rs.getFieldValues())) {
throw new IllegalStateException("Cannot read server_id; grant REPLICATION CLIENT/SUPER to the canal user.");
} Prevention
- 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.
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- unexpected binlog format query result: + rs.getFieldValues()
- command : ' + showSql + ' has an error! pls check. you need
- Error When doing Register slave: + err.toString()
- unexpected binlog image query result: + rs.getFieldValues()
- command : show variables like 'server_id' has an error!
AI-assisted analysis of alibaba/canal@87be50e876 (2026-08-14).
Data as JSON: /api/errors/5dd333b31019d02f.
Report an issue: GitHub.