这是我的代码:
String cmd = "\"C:\\Program Files\\MySQL\\MySQL Server 5.6\\bin\\mysqldump\" -h www.anonymizeddomain.com -u root -proot anon_thisdb > anon_thisdb.sql\"";
Process proc = Runtime.getRuntime().exec(cmd);
Print(cmd);
InputStream stdin = proc.getInputStream();
InputStreamReader isr = new InputStreamReader(stdin);
BufferedReader br = new BufferedReader(isr);
String line = null;
System.out.println("<OUTPUT>");
while ( (line = br.readLine()) != null)
System.out.println(line);
System.out.println("</OUTPUT>");
int exitVal = proc.waitFor();
System.out.println("Process exitValue: " + exitVal);
它以错误代码6退出并且idk为什么。我从控制台得到的输出是:
<OUTPUT>
-- MySQL dump 10.13 Distrib 5.6.13, for Win64 (x86_64)
--
-- Host: www.anonymizeddomain.com Database: anon_thisdb
-- ------------------------------------------------------
-- Server version 5.5.32-cll-lve
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8 */;
/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
/*!40103 SET TIME_ZONE='+00:00' */;
/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
</OUTPUT>
Process exitValue: 6
冰棒切片我做错了什么?!
我把转义字符放在字符串中,所以我不会得到错误,但是我得到了错误:\什么是软糖? :\