{"record":{"id":"e17a15e08e7e4550","repo":"apache/seatunnel","slug":"error-reading-mysql-variables","errorCode":null,"errorMessage":"Error reading MySQL variables: ","messagePattern":"Error reading MySQL variables: ","errorType":"exception","errorClass":"DebeziumException","httpStatus":null,"severity":"error","filePath":"seatunnel-connectors-v2/connector-cdc/connector-cdc-mysql/src/main/java/io/debezium/connector/mysql/MySqlConnection.java","lineNumber":172,"sourceCode":"        final Map<String, String> variables = new HashMap<>();\n        try {\n            query(\n                    statement,\n                    rs -> {\n                        while (rs.next()) {\n                            String varName = rs.getString(1);\n                            String value = rs.getString(2);\n                            if (varName != null && value != null) {\n                                variables.put(varName, value);\n                                LOGGER.debug(\n                                        \"\\t{} = {}\",\n                                        Strings.pad(varName, 45, ' '),\n                                        Strings.pad(value, 45, ' '));\n                            }\n                        }\n                    });\n        } catch (SQLException e) {\n            throw new DebeziumException(\"Error reading MySQL variables: \" + e.getMessage(), e);\n        }\n\n        return variables;\n    }\n\n    protected String setStatementFor(Map<String, String> variables) {\n        StringBuilder sb = new StringBuilder(\"SET \");\n        boolean first = true;\n        List<String> varNames = new ArrayList<>(variables.keySet());\n        Collections.sort(varNames);\n        for (String varName : varNames) {\n            if (first) {\n                first = false;\n            } else {\n                sb.append(\", \");\n            }\n            sb.append(varName).append(\"=\");\n            String value = variables.get(varName);","sourceCodeStart":154,"sourceCodeEnd":190,"githubUrl":"https://github.com/apache/seatunnel/blob/cf67b549a7a6c35fa0beb12d83c62892427ea919/seatunnel-connectors-v2/connector-cdc/connector-cdc-mysql/src/main/java/io/debezium/connector/mysql/MySqlConnection.java#L154-L190","documentation":"MySqlConnection.querySystemVariables runs a SQL query (e.g. SHOW VARIABLES) over a JDBC connection and wraps any SQLException into a DebeziumException with this message. It means the connector could not read MySQL server system variables needed to build its connection context. The original SQLException is preserved as the cause.","triggerScenarios":"Any SQLException thrown while executing the variables query inside querySystemVariables, invoked via readMySqlCharsetSystemVariables, readMySqlSystemVariables, or sessionVariables — e.g. connection dropped mid-query, bad credentials, unknown database, or server refused the statement.","commonSituations":"Wrong hostname/port or firewall blocking the DB during connector startup; MySQL user lacking privileges to execute SHOW VARIABLES; server restarted or connection timed out; SSL/TLS mismatch between driver and server.","solutions":["Verify MySQL host, port, username and password in the connector configuration and test with a mysql client","Confirm the MySQL user can connect and run SHOW VARIABLES (grant as needed)","Check network reachability, firewall rules, and TLS settings between the connector and MySQL","Inspect the wrapped SQLException (cause) for the root cause and fix accordingly"],"exampleFix":"// before: generic user/password\nMySQLConnection config = MySqlConnection.create(\n    MySqlConnectionConfiguration.builder()\n        .withHostname(\"wrong-host\") ... );\n// after: verified reachable endpoint\nMySQLConnection config = MySqlConnection.create(\n    MySqlConnectionConfiguration.builder()\n        .withHostname(\"mysql.internal\")\n        .withPort(3306)\n        .withUser(\"debezium\")\n        .withPassword(\"secret\") ... );","handlingStrategy":"try-catch","validationCode":"try (Connection c = DriverManager.getConnection(url, user, pass)) { try (Statement s = c.createStatement(); ResultSet rs = s.executeQuery(\"SHOW VARIABLES\")) { rs.next(); } }","typeGuard":null,"tryCatchPattern":"try { mysqlConnection.sessionVariables(); } catch (DebeziumException e) { logger.error(\"Failed to read MySQL variables\", e.getCause()); /* fail fast or retry with backoff */ }","preventionTips":["Validate DB connectivity with a mysql client before starting the connector","Use a dedicated CDC user with SHOW VARIABLES privileges","Set sane connection timeouts and test TLS config early","Monitor DB health/restarts around connector startup"],"tags":["mysql","jdbc","sql-exception","cdc"],"backgroundTag":"database-query-failed","analyzedSha":"cf67b549a7a6c35fa0beb12d83c62892427ea919","analyzedAt":"2026-09-10T21:44:55.265Z","contentChangedAt":"2026-09-10T21:44:55.265Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}