【发布时间】:2012-12-06 15:40:00
【问题描述】:
我正在尝试备份一个 mysql 数据库。 我创建的代码是
ProcessStartInfo proc = new ProcessStartInfo();
string cmd = string.Format(@"-u{0} -p{1} -E -R -h{2} {3}", UserName, PWD, hostname, dbname);
proc.FileName = "Path to mysqldump.exe";
proc.RedirectStandardInput = false;
proc.RedirectStandardOutput = true;
proc.Arguments = cmd;
proc.UseShellExecute = false;
Process p = Process.Start(proc);
string res;
res = p.StandardOutput.ReadToEnd();
file.WriteLine(res);
p.WaitForExit();
file.Close();
问题是当数据库大小较小时它可以正常工作,但是当我尝试备份大型数据库(大约 800 MB)时我得到Out Of Memory Exception。
【问题讨论】:
-
错误信息解释了很多事情。C盘中有多少空间决定了备份操作的空间,因为在进行备份或任何凝乳内存管理时会使用临时内存。
-
@Pratik 大约有 64 GB 可用空间......
-
读取数据库文件的方法您可以发布示例,因为这可能是原因