MyCATApache/Mycat-Server · critical · RuntimeException
${e}
Error message
${e} What it means
querySecurePath runs 'show variables like secure_file_priv' to discover where MySQL permits LOAD DATA/SELECT INTO OUTFILE files. A SQLException during the connection or query is rethrown as a RuntimeException, failing the dump runner before migration can proceed.
Solutions
- Check config.getUrl(), user and password resolve to a reachable MySQL server.
- Confirm the server supports secure_file_priv (MySQL >= 5.7.6); check with SHOW VARIABLES LIKE 'secure_file_priv'.
- Inspect the wrapped SQLException in the stack trace for the root cause (timeout, access denied, unknown host).
- If the variable is absent on your server, set a path manually or upgrade MySQL so OUTFILE-based transfer works.
Example fix
// before
con = DriverManager.getConnection("jdbc:mysql://" + config.getUrl(), config.getUser(), config.getPassword());
// after
try (Connection con = DriverManager.getConnection("jdbc:mysql://" + config.getUrl(), config.getUser(), config.getPassword())) {
// wrap the RuntimeException with context
} catch (SQLException e) {
throw new RuntimeException("Failed to query secure_file_priv from " + config.getUrl(), e);
} Defensive patterns
Strategy: validation
Validate before calling
// before running dump
Class.forName("com.mysql.jdbc.Driver");
try (Connection c = DriverManager.getConnection("jdbc:mysql://" + config.getUrl(), config.getUser(), config.getPassword())) {
ResultSet rs = c.createStatement().executeQuery("SHOW VARIABLES LIKE 'secure_file_priv'");
if (!rs.next()) throw new IllegalStateException("secure_file_priv unsupported/absent");
} Try / catch
try { spath(); } catch (RuntimeException e) {
if (e.getCause() instanceof java.sql.SQLException sql) {
// log sql.getErrorCode()/getSQLState(), decide retry vs abort
}
throw e;
} Prevention
- Test the JDBC URL with a plain mysql client before migration
- Require MySQL >= 5.7.6 so secure_file_priv exists
- Run SHOW VARIABLES check as a preflight in CI
- Keep migration user privileges minimal but sufficient (SHOW VARIABLES, file ops)
When it happens
Trigger: DriverManager.getConnection(config.getUrl()) fails (bad URL, auth, network); 'show variables like secure_file_priv' is rejected or the connection drops; the result set lacks the expected 'Value' row.
Common situations: MySQL 5.6- and MariaDB without the secure_file_priv variable (list is empty, path stays null and later file operations fail); wrong JDBC URL in config; the migration user cannot execute SHOW VARIABLES.
Understand the failure class
Background: Database query failed: Internal Server Error 500s wrapping SQL, Prisma, and connection failures — what to check first — this error's family across 16 libraries.
Related errors
- ${e}
- global seq and share join and special…
- fetching sequence can not support the db driver
- CallableStatement not supported
- Unexpected exception
AI-assisted analysis of MyCATApache/Mycat-Server@65f8d8beb7 (2026-09-11).
Data as JSON: /api/errors/6e6dcddfddf19490.
Report an issue: GitHub.
Appendix: source
Thrown at src/main/java/io/mycat/migrate/MigrateDumpRunner.java:220
} else {
whereList.add("(_slot >=" + slotRange.start + " and _slot <=" + slotRange.end + ")");
}
}
return Joiner.on(" or ").join(whereList);
}
private static String querySecurePath(DBHostConfig config) {
List<Map<String, Object>> list = null;
String path = null;
Connection con = null;
try {
con = DriverManager.getConnection("jdbc:mysql://" + config.getUrl(), config.getUser(), config.getPassword());
list = executeQuery(con, "show variables like 'secure_file_priv'");
if (list != null && list.size() == 1)
path = (String) list.get(0).get("Value");
} catch (SQLException e) {
throw new RuntimeException(e);
} finally {
JdbcUtils.close(con);
}
return path;
}
public static void main(String[] args) {
String result = "\n" + "--\n" + "-- Position to start replication or point-in-time recovery from\n" + "--\n"
+ "\n" + "CHANGE MASTER TO MASTER_LOG_FILE='NANGE-PC-bin.000021', MASTER_LOG_POS=154;\n";
int logIndex = result.indexOf("MASTER_LOG_FILE='");
int logPosIndex = result.indexOf("MASTER_LOG_POS=");
String logFile = result.substring(logIndex + 17, logIndex + 17 + result.substring(logIndex + 17).indexOf("'"));
String logPos = result.substring(logPosIndex + 15, logPosIndex + 15 + result.substring(logPosIndex + 15).indexOf(";"));
System.out.println(logFile + logPos);
}
}
View on GitHub (pinned to 65f8d8beb7)