, , , , , , ,

How to take back up of my sql database using C#

downloadYou can also download running code.

Taking a back up of my sql using C# is very easy but this also be termed as tricky backup. Like Sql server my sql does not provide built in stored procedures to take back up. For back up my sql use a Exe file named “mysqldump.exe”

You will find this Exe file in “C:\Program Files\MySQL\MySQL Server 5.0\bin” folder of mySql.

This file takes so many parameters for different options. But my task is to simply take a backup of single database

To take a backup of single database following are the parameters

mysqldump -u<usernane> -p <password> -h<servername or ip> <databasename> > <localtion to take backup>

Please let me know if this helps you to perform your task easily.
Share:

6 comments:

Anonymous said...

hello sir,
i have seen your example but when i change the path of back file then its not working even its not created a single file according to my path. i don't know whats wrong with it.

private void button1_Click(object sender, EventArgs e)
{
this.Cursor = Cursors.WaitCursor;
BackUpMySql backUpMySql = new BackUpMySql();
backUpMySql.BackupMySQLDatabase("server_con", "localhost", "root", "psr", "D:\\Temp.sql", Environment.CurrentDirectory);
this.Cursor = Cursors.Default;
MessageBox.Show("Backup completed sucessfully.", "AnITSolution", MessageBoxButtons.OK, MessageBoxIcon.Information);
}

just check it sir.....

thanks in Advance
Naim Khan

Anonymous said...

hello sir,
i have seen your example but when i change the path of back file then its not working even its not created a single file according to my path. i don't know whats wrong with it.

private void button1_Click(object sender, EventArgs e)
{
this.Cursor = Cursors.WaitCursor;
BackUpMySql backUpMySql = new BackUpMySql();
backUpMySql.BackupMySQLDatabase("server_con", "localhost", "root", "psr", "D:\\Temp.sql", Environment.CurrentDirectory);
this.Cursor = Cursors.Default;
MessageBox.Show("Backup completed sucessfully.", "AnITSolution", MessageBoxButtons.OK, MessageBoxIcon.Information);
}

just check it sir.....

thanks in Advance
Naim Khan

An IT Solution said...

Hi Naim,

I had studied ur code but I have not found anything wrong in that, please put a pointer a let me know the exact error.

Check you user id and password and server name from which you wants to take a backup.

Thanks,
Narender Singh

Diya said...

Hello dear

I read your blog and found it interesting. What if we can share info with you.

I would like to add some of my post on your blog. that will be beneficial for both of us. you will get content rich and gud post.

Tell me your response. plz

An IT Solution said...

Diya,

I don't have any issue posting your content. Please share your articles, if I will find the articles unique and useful, I will post the same on my blog.

can solve a number of problems said...

This makes my life really easier. I once should find a backup but this was an hour of monotonous looking among the files and folders.