我是靠谱客的博主 鲜艳咖啡,最近开发中收集的这篇文章主要介绍.net mysql 备份,如何使用c#.net备份和恢复MySQL数据库,觉得挺不错的,现在分享给大家,希望可以做个参考。

概述

Hi........

I am doing a windows application in that i used MySQL as back end.I want to take the backup of Database by writing code in c#.net. If any body knows please send me that code. I googled but no use. I found one code but but its coming for 1st table only. I wan the whole Database.

This is the code which i used...try

{

DateTime backupTime = DateTime.Now;

int year = backupTime.Year;

int month = backupTime.Month;

int day = backupTime.Day;

int hour = backupTime.Hour;

int minute = backupTime.Minute;

int second = backupTime.Second;

int ms = backupTime.Millisecond;

String tmestr = backupTime.ToString();

tmestr = "D:\" + year + "-" + month + "-" + day + "-" + hour + "-" + minute + ".sql";

StreamWriter file = new StreamWriter(tmestr);

ProcessStartInfo proc = new ProcessStartInfo();

string cmd = string.Format(@"-u{0} -p{1} -h{2} {3} ", "root", "sa", "localhost", "employee", "backup.sql");

proc.FileName = @"C:Program FilesMySQLMySQL Server 5.0binmysqldump";

proc.RedirectStandardInput = false;

proc.RedirectStandardOutput = true;

proc.Arguments = cmd;//"-u root -p smartdb > testdb.sql";

proc.UseShellExecute = false;

Process p = Process.Start(proc);

string res;

res = p.StandardOutput.ReadToEnd();

file.WriteLine(res);

p.WaitForExit();

file.Close();

MessageBox.Show("Backup Done");

}

catch (IOException ex)

{

MessageBox.Show("Disk full or other IO error , unable to backup!");

}

But its coming for the 1st table only...

I want the whole database.

Thanks in advance......

解决方案I can only assume that you didn''t google very hard, or used a poor search phrase.

I just tried, using c# mysql backup and the first few hits that I looked at had code samples.

最后

以上就是鲜艳咖啡为你收集整理的.net mysql 备份,如何使用c#.net备份和恢复MySQL数据库的全部内容,希望文章能够帮你解决.net mysql 备份,如何使用c#.net备份和恢复MySQL数据库所遇到的程序开发问题。

如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(69)

评论列表共有 0 条评论

立即
投稿
返回
顶部