{"record":{"id":"2001e4f16314915a","repo":"MyCATApache/Mycat-Server","slug":"errmessage-mysqldump","errorCode":null,"errorMessage":"{errMessage} -> {mysqlDump}","messagePattern":"\\{errMessage\\} -> \\{mysqlDump\\}","errorType":"exception","errorClass":"DataMigratorException","httpStatus":null,"severity":"error","filePath":"src/main/java/io/mycat/util/dataMigrator/dataIOImpl/MysqlDataIO.java","lineNumber":131,"sourceCode":"\t\t\tif(data.startsWith(\",\")){\n\t\t\t\tdata = data.substring(1, data.length());\n\t\t\t}\n\t\t\tif(data.endsWith(\",\")){\n\t\t\t\tdata = data.substring(0,data.length()-1);\n\t\t\t}\n\t\t\tString mysqlDumpCmd = DataMigratorUtil.paramsAssignment(mysqlDump,\"#\",data);\n\t\t\tLOGGER.info(table.getSchemaAndTableName()+mysqlDump);\n\t\t\tLOGGER.debug(table.getSchemaAndTableName()+\" \"+mysqlDumpCmd);\n\n\t\t\tProcess process = DataMigratorUtil.exeCmdByOs(mysqlDumpCmd);\n\t\t\t//获取错误信息\n\t\t\tInputStreamReader in = new InputStreamReader(process.getErrorStream());\n\t\t\tBufferedReader br = new BufferedReader(in);\n\t\t\tString errMessage = null;\n\t        while ((errMessage = br.readLine()) != null) {\n\t            if(errMessage.trim().toLowerCase().contains(\"err\")){\n\t            \tSystem.out.println(errMessage+\" -> \"+mysqlDump);\n\t            \tthrow new DataMigratorException(errMessage+\" -> \"+mysqlDump);\n\t            }else{\n\t            \tLOGGER.info(table.getSchemaAndTableName()+mysqlDump+\" exe info:\"+errMessage);\n\t            }\n\t        }\n\t\t\tprocess.waitFor();\n\n\t\t\t//合并文件\n\t\t\tDataMigratorUtil.mergeFiles(mergedFile, exportFile);\n\t\t\tif(exportFile.exists()){\n\t\t\t\texportFile.delete();\n\t\t\t}\n\t\t}\n\t\treturn mergedFile;\n\t}\n}\n","sourceCodeStart":113,"sourceCodeEnd":147,"githubUrl":"https://github.com/MyCATApache/Mycat-Server/blob/65f8d8beb752f935752f2a0eec0ab017facab9ef/src/main/java/io/mycat/util/dataMigrator/dataIOImpl/MysqlDataIO.java#L113-L147","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Run the printed mysqldump command manually to see the real error and fix credentials, schema/table names, or options.","Align mysqldump client version with the server version (e.g. add --column-statistics=0 for newer clients against older servers).","Verify the migration config's source connection (host, port, user, password, schema) is correct.","Ensure mysqldump is installed and on PATH for the user running the migration."],"exampleFix":"// before\nString cmd = mysqldump + \" -h\" + host + \" -P\" + port + \" -u\" + user + \" -p\" + password + \" \" + schema + \" \" + table;\n// after\nString cmd = mysqldump + \" -h\" + host + \" -P\" + port + \" -u\" + user + \" -p\" + password\n    + \" --column-statistics=0 --single-transaction \" + schema + \" \" + table;","handlingStrategy":"validation","validationCode":"// before export\nProcess p = new ProcessBuilder(\"which\", \"mysqldump\").start();\nif (p.waitFor() != 0) throw new IllegalStateException(\"mysqldump not on PATH\");\n// verify source connectivity\ntry (Connection c = DriverManager.getConnection(srcUrl, srcUser, srcPass)) {\n  c.createStatement().execute(\"SELECT 1\");\n}","typeGuard":null,"tryCatchPattern":"try {\n  dataIO.exportData(...);\n} catch (DataMigratorException e) {\n  logger.error(\"mysqldump failed: {}\", e.getMessage()); // rerun printed mysqldump command to see full stderr\n}","preventionTips":["Run the mysqldump command once manually before automating the migration.","Match mysqldump client version with the server version (add --column-statistics=0 when needed).","Validate source credentials and schema/table existence before the export."],"tags":["data-migration","external-process","mysqldump","export"],"backgroundTag":"database-query-failed","analyzedSha":"65f8d8beb752f935752f2a0eec0ab017facab9ef","analyzedAt":"2026-09-11T00:12:21.696Z","contentChangedAt":"2026-09-11T00:12:21.696Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}