如何执行大型数据库MySQL服务器的备份 [英] How to execute backup of large database of mysql server

查看:132
本文介绍了如何执行大型数据库MySQL服务器的备份的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建一个Web应用程序。
而在该应用程序我需要很多MySQL数据库的备份。

I'm creating a web application. And in that application i need to take backup of many MySQL databases.

有关,我创造了它正常工作的小型数据库,但波谷例外选项
内存溢出异常对于大型数据库。

For that i created an option it works fine on small databases but troughs exception Out of memory exception for large databases.

请注意: - 有足够的可用磁盘空间既Web服务器和数据库服务器上的

Note:- There is enough disc space available on both web server and database server.

和还有些时间它工作得很好,有的时候它创建的备份文件1 KB大小。

And also some time it works very fine and some time it creates 1 kb size of backup files.

public static string DatabaseBackup(string ExeLocation,
    string DBName,
    string Ip,
    string Uid,
    string Pass,
    string FileNm)
{
    string status = "";
    try
    {
        StreamWriter file = new StreamWriter(FileNm);
        ProcessStartInfo proc = new ProcessStartInfo();
        string cmd = string.Format(@"-u{0} -p{1} -h{2} {3}", Uid, Pass, Ip, DBName);
        proc.FileName = ExeLocation;
        proc.RedirectStandardInput = false;
        proc.RedirectStandardOutput = true;
        proc.Arguments = cmd;
        proc.UseShellExecute = false;
        proc.CreateNoWindow = true;
        Process p = Process.Start(proc);
        string res;
        res = p.StandardOutput.ReadToEnd();
        file.WriteLine(res);
        p.WaitForExit();
        file.Close();
        status = "OK";
    }
    catch (Exception ex)
    {
        status = ex.Message;
    }
    return status;
}

任何一个可以帮助我什么是错误的,我怎么能解决这两个问题。

Can any one help me what is wrong and how can i solve both problems.

推荐答案

如果您正在阅读它的文件的更大然后可用内存异常将被抛出。检查在这篇文章中如何处理大型文件以及如何prevent内存溢出异常<一个href=\"http://stackoverflow.com/questions/1862982/c-sharp-filestream-optimal-buffer-size-for-writing-large-files\">C#的FileStream:最佳缓冲区大小写大文件

if the file you are reading it's bigger then your available memory an exception will be thrown. check in this article how to process large files and how to prevent out of memory exception C# FileStream : Optimal buffer size for writing large files?

这篇关于如何执行大型数据库MySQL服务器的备份的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆