我正在写一个应用程序,它应该制作一个数据库的完整副本,然后将其导入不同名称的同一服务器上。
所以,我想我应该使用mysqldump和mysql以及我应该传递给它们的参数。
好的,但是我不能让转储把文件放到我想要的地方,因为我必须知道文件的位置,然后把它传递给mysql。
StringBuilder exportPath = new StringBuilder();
//exportPath.Append(Directory.GetCurrentDirectory());
exportPath.Append(@" > C:\Temp\backup.sql");
Process MySQLDump = new Process();
MySQLDump.StartInfo.UseShellExecute = true;
//MySQLDump.StartInfo.RedirectStandardOutput = true;
MySQLDump.StartInfo.FileName = "mysqldump";
MySQLDump.StartInfo.Arguments = "-u root -proot -h localhost mytable" + exportPath;
MySQLDump.Start();
//string theDump = MySQLDump.StandardOutput.ReadToEnd();
MySQLDump.WaitForExit();
MySQLDump.Close();我做错了什么,但我不知道是什么。
发布于 2013-05-10 21:56:46
您有两个选择:
> C:\\Documents and Settings\\admin\\Desktop\\databases\\db.sql不是命令行参数。您需要对参数和重定向部分字符串进行,并使用shell执行sssemble。请确保使用绝对路径名。https://stackoverflow.com/questions/16483871
复制相似问题