获取备份到数据库mysql [英] Get Backup to database mysql
问题描述
您好,
我正在尝试备份到mysql数据库。我用过这段代码
Hello,
i'm trying to get backup to mysql database. I used this code
private void button1_Click(object sender, EventArgs e)
{
string Coonstring = "datasource=localhost;port=3306;username=****;password=****;Charset=utf8";
MySqlConnection cn= new MySqlConnection(Coonstring);
MySqlCommand cmd;
SaveFileDialog sf = new SaveFileDialog();
sf.Filter = "Backup Files (*.Bak) |*.bak";
if(sf.ShowDialog()==DialogResult.OK)
{
cmd = new MySqlCommand("Backup Database project To Disk='" + sf.FileName + "'", cn);
cn.Open();
cmd.ExecuteNonQuery();
MessageBox.Show("Done");
cn.Close();
}
}
但我收到错误(类型'MySql.Data.MySqlClient的未处理异常。 MySqlException'发生在MySql.Data.dll中
附加信息:您的SQL语法有错误;请查看与您的MySQL服务器版本对应的手册在'备份数据库项目到磁盘='C:\ Users \ tariq emad \Desktop \\\\tt.bak''第1行附近使用的语法。
那么,任何人都可以帮我修复这个错误吗?
but i get error ( An unhandled exception of type 'MySql.Data.MySqlClient.MySqlException' occurred in MySql.Data.dll
Additional information: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'Backup Database project To Disk='C:\Users\tariq emad\Desktop\1\tt.bak'' at line 1).
So, any one can help me to fix this error?
推荐答案
Mysql本身没有备份命令(就像代码中的MSSQL一样) ,阅读以下有关如何备份的内容: http://webcheatsheet.com/sql/mysql_backup_restore.php [ ^ ]
Mysql does not natively have backup command (like the MSSQL one in your code), read the following on how to backup : http://webcheatsheet.com/sql/mysql_backup_restore.php[^]
亲爱的Mehdi,
这个我s通过shell或telnet。
我需要它来自C#按钮代码
问候
Dear Mehdi,
this is via shell or telnet.
I need it from C# button code
Regards
这篇关于获取备份到数据库mysql的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!