C# 如何使用C备份特定的MySQL表#
我一直在用C#备份MySQL表。我不知道如何在MySQL模式中备份特定的表。如何使用C#仅备份一个或两个特定表?根据,您可以使用名为C# 如何使用C备份特定的MySQL表#,c#,mysql,mysql-backup,mysqlbackup.net,C#,Mysql,Mysql Backup,Mysqlbackup.net,我一直在用C#备份MySQL表。我不知道如何在MySQL模式中备份特定的表。如何使用C#仅备份一个或两个特定表?根据,您可以使用名为TablesToBeExportedList的列表属性在MySqlBackup.ExportInfo中指定它 因此,类似这样的方法应该会奏效: string constring = "server=localhost;user=root;pwd=1234;database=test1;"; string file = "Y:\\backup.sql"; using
TablesToBeExportedList
的列表属性在MySqlBackup.ExportInfo
中指定它
因此,类似这样的方法应该会奏效:
string constring = "server=localhost;user=root;pwd=1234;database=test1;";
string file = "Y:\\backup.sql";
using (MySqlConnection conn = new MySqlConnection(constring))
{
using (MySqlCommand cmd = new MySqlCommand())
{
using (MySqlBackup mb = new MySqlBackup(cmd))
{
cmd.Connection = conn;
conn.Open();
mb.ExportInfo.TablesToBeExportedList = new List<string> {
"Table1",
"Table2"
};
mb.ExportToFile(file);
}
}
}
string constring=“server=localhost;user=root;pwd=1234;database=test1;”;
string file=“Y:\\backup.sql”;
使用(MySqlConnection conn=新的MySqlConnection(consting))
{
使用(MySqlCommand cmd=new MySqlCommand())
{
使用(MySqlBackup mb=newmysqlbackup(cmd))
{
cmd.Connection=conn;
conn.Open();
mb.ExportInfo.TablesToBeExportedList=新列表{
“表1”,
“表2”
};
导出文件(文件);
}
}
}
我尝试了您的解决方案,但它也导出了函数和视图,我怎么能在导出的结果中忽略函数和视图?我必须将这些属性设置为false
``mb.ExportInfo.ExportFunctions=false;mb.ExportInfo.exportview=false;mb.ExportInfo.ExportTriggers=false;mb.ExportInfo.ExportEvents=false;mb.ExportInfo.ExportProcedures=false;mb.ExportInfo.ExportRoutinesWithoutDefiner=false```