{"record":{"id":"8e32ed2932ed4bec","repo":"apache/seatunnel","slug":"error-reading-default-database-charsets","errorCode":null,"errorMessage":"Error reading default database charsets: ","messagePattern":"Error reading default database charsets: ","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":544,"sourceCode":"                    rs -> {\n                        final Map<String, DatabaseLocales> charsets = new HashMap<>();\n                        while (rs.next()) {\n                            String dbName = rs.getString(1);\n                            String charset = rs.getString(2);\n                            String collation = rs.getString(3);\n                            if (dbName != null && (charset != null || collation != null)) {\n                                charsets.put(dbName, new DatabaseLocales(charset, collation));\n                                LOGGER.debug(\n                                        \"\\t{} = {}, {}\",\n                                        Strings.pad(dbName, 45, ' '),\n                                        Strings.pad(charset, 45, ' '),\n                                        Strings.pad(collation, 45, ' '));\n                            }\n                        }\n                        return charsets;\n                    });\n        } catch (SQLException e) {\n            throw new DebeziumException(\n                    \"Error reading default database charsets: \" + e.getMessage(), e);\n        }\n    }\n\n    public MySqlConnectionConfiguration connectionConfig() {\n        return connectionConfig;\n    }\n\n    public String connectionString() {\n        return connectionString(URL_PATTERN);\n    }\n\n    public static String getJavaEncodingForMysqlCharSet(String mysqlCharsetName) {\n        return CharsetMappingWrapper.getJavaEncodingForMysqlCharSet(mysqlCharsetName);\n    }\n\n    /** Helper to gain access to protected method */\n    private static final class CharsetMappingWrapper extends CharsetMapping {","sourceCodeStart":526,"sourceCodeEnd":562,"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#L526-L562","documentation":"readDatabaseCollations() queries information_schema.schemata for each database's default character set and collation; any SQLException is rethrown as a DebeziumException with this message and the server's error text appended. It means the connector could not read default charsets while preparing the snapshot schema. The query target (information_schema) exists on all supported servers, so this is almost always a privilege, connection, or server availability problem.","triggerScenarios":"Calling MySqlConnection.readDatabaseCollations() (from snapshot schema reading) when the JDBC connection is broken, when the error message says the user is denied (rare information_schema restrictions / partial_revokes), or when the server drops the connection mid-query on large information_schema scans.","commonSituations":"Network interruption or MySQL wait_timeout killing an idle connection during snapshot; revoked SELECT on information_schema via partial_revokes; connection terminated by a proxy or by server restart mid-snapshot; extremely many schemas causing query timeout.","solutions":["Read the appended `e.getMessage()` for the actual MySQL error and address that specific cause.","Check/reestablish connectivity to MySQL; raise wait_timeout or ensure the connection is fresh at snapshot start.","Grant the CDC user broad SELECT access: GRANT SELECT ON *.* TO 'user'@'%'; so information_schema.schemata is readable.","If partial_revokes restricts access, remove the offending revocations or capture fewer databases.","Retry the job — a transient drop during snapshot is typically recoverable on a fresh connection."],"exampleFix":"-- before: user restricted to one DB on MySQL 8 with partial_revokes\nREVOKE SELECT ON `otherdb`.* FROM 'stuser'@'%';\n-- after: allow full catalog visibility for CDC snapshot\nGRANT SELECT ON *.* TO 'stuser'@'%';","handlingStrategy":"retry","validationCode":"// Validate access and connection stability beforehand:\n// mysql -u stuser -p -h <host> -e \"SELECT schema_name FROM information_schema.schemata LIMIT 1;\"\n// Also confirm wait_timeout is not aggressively low for the job's connection.","typeGuard":null,"tryCatchPattern":"try {\n    runSnapshot(); // internally calls readDatabaseCollations()\n} catch (DebeziumException e) {\n    if (e.getMessage().contains(\"Error reading default database charsets\")) {\n        // transient connection drop is the usual cause: wait and retry the job\n        Thread.sleep(5000);\n        retryWithBackoff(3);\n    } else {\n        throw e;\n    }\n}","preventionTips":["Raise MySQL wait_timeout/net_write_timeout or keep connections active during long snapshots.","Grant SELECT on *.* so information_schema.schemata is fully readable.","Watch for partial_revokes in MySQL 8 restricting catalog visibility.","Run snapshots against a stable primary rather than a flaky replica/proxy."],"tags":["mysql","cdc","jdbc","information-schema","charset"],"backgroundTag":"sql-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"}