What is MySQLDUMP?
The mysqldump is console based executable utility and it allows us to assign a host of options to get the backup of a database to a file, a different MySQL server running anywhere in the world .
In fact MySQL does not backup our data instead of that it executes a set of basic sql syntaxes like "create table" and "insert into" in the MySQL server to re-create the database/s.
The mysqldump utility is present in the root directory of mysql, let us assume it is c:\mysql and you could find a folder bin in that directory. Using the mysqldump utility we can provide several commands so that we can change the way of taking backups.
1.Using This Command First You Will Download XAMPP
2.And Install It
3.After Installing Open Command Prompt
4.Go to [C:\xampp\mysql\bin] Folder Using cd Command
Like CD C:\xampp\mysql\bin
5.Now Type Command
mysqldump -hHostname -uUsername DatabaseName > FileName
Example
mysqldump -h127.0.0.1 -uroot TestDB > TestDB.sql
With Password
mysqldump -h127.0.0.1 -uroot -p123 TestDB > TestDB.sql
Now In C#
if (File.Exists(Application.StartupPath + "\\mysqldump.exe"))
{
try
{
using (StreamWriter sw = new StreamWriter (Application.StartupPath + "\\dump.bat"))
{
sw.Write("mysqldump -h127.0.0.1 -uroot -p123 TestDB > TestDB.sql");
sw.Close();
}
Shell(Application.StartupPath + "\\dump.bat", AppWinStyle.Hide , false);
File.Delete(Application.StartupPath + "\\dump.bat");
}
catch (Exception ex)
{}
}
else
{
MessageBox.Show("MySqlDump.Exe Not Found.");
}
No comments:
Post a Comment