MyCATApache/Mycat-Server · error · DataMigratorException

->

Error message

{errMessage} -> {mysqlDump}

What it means

During exportData, MysqlDataIO spawns mysqldump as an external process and inspects its stderr. Any line containing the substring "err" (case-insensitive) causes a DataMigratorException embedding the stderr line and the mysqldump command; all other lines are just logged. The naive substring test means warning lines that merely contain 'err' can abort an otherwise successful dump.

Solutions

  1. Run the printed mysqldump command manually to see the real error and fix credentials, schema/table names, or options.
  2. Align mysqldump client version with the server version (e.g. add --column-statistics=0 for newer clients against older servers).
  3. Verify the migration config's source connection (host, port, user, password, schema) is correct.
  4. Ensure mysqldump is installed and on PATH for the user running the migration.

Example fix

// before
String cmd = mysqldump + " -h" + host + " -P" + port + " -u" + user + " -p" + password + " " + schema + " " + table;
// after
String cmd = mysqldump + " -h" + host + " -P" + port + " -u" + user + " -p" + password
    + " --column-statistics=0 --single-transaction " + schema + " " + table;
Defensive patterns

Strategy: validation

Validate before calling

// before export
Process p = new ProcessBuilder("which", "mysqldump").start();
if (p.waitFor() != 0) throw new IllegalStateException("mysqldump not on PATH");
// verify source connectivity
try (Connection c = DriverManager.getConnection(srcUrl, srcUser, srcPass)) {
  c.createStatement().execute("SELECT 1");
}

Try / catch

try {
  dataIO.exportData(...);
} catch (DataMigratorException e) {
  logger.error("mysqldump failed: {}", e.getMessage()); // rerun printed mysqldump command to see full stderr
}

Prevention

When it happens

Trigger: Running exportData when mysqldump writes an error to stderr: unknown table/schema, access denied, mysqldump not found, unsupported option, or connection failure to the source MySQL server.

Common situations: Wrong MySQL credentials in migration config, source schema/table renamed or dropped, mysqldump version incompatible with server (e.g. newer client vs older server raising 'column statistics' errors), mysqldump missing from PATH.

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


AI-assisted analysis of MyCATApache/Mycat-Server@65f8d8beb7 (2026-09-11). Data as JSON: /api/errors/2001e4f16314915a. Report an issue: GitHub.

Appendix: source

Thrown at src/main/java/io/mycat/util/dataMigrator/dataIOImpl/MysqlDataIO.java:131

			if(data.startsWith(",")){
				data = data.substring(1, data.length());
			}
			if(data.endsWith(",")){
				data = data.substring(0,data.length()-1);
			}
			String mysqlDumpCmd = DataMigratorUtil.paramsAssignment(mysqlDump,"#",data);
			LOGGER.info(table.getSchemaAndTableName()+mysqlDump);
			LOGGER.debug(table.getSchemaAndTableName()+" "+mysqlDumpCmd);

			Process process = DataMigratorUtil.exeCmdByOs(mysqlDumpCmd);
			//获取错误信息
			InputStreamReader in = new InputStreamReader(process.getErrorStream());
			BufferedReader br = new BufferedReader(in);
			String errMessage = null;
	        while ((errMessage = br.readLine()) != null) {
	            if(errMessage.trim().toLowerCase().contains("err")){
	            	System.out.println(errMessage+" -> "+mysqlDump);
	            	throw new DataMigratorException(errMessage+" -> "+mysqlDump);
	            }else{
	            	LOGGER.info(table.getSchemaAndTableName()+mysqlDump+" exe info:"+errMessage);
	            }
	        }
			process.waitFor();

			//合并文件
			DataMigratorUtil.mergeFiles(mergedFile, exportFile);
			if(exportFile.exists()){
				exportFile.delete();
			}
		}
		return mergedFile;
	}
}

View on GitHub (pinned to 65f8d8beb7)