If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > MySQL > back up

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 09-19-11, 22:06
tokollo tokollo is offline
Registered User
 
Join Date: Sep 2011
Posts: 1
back up

These code doesn't back up the entire database.Can someone tell me why please?


public void Backup()
{
string tmestr = "";
tmestr = "mudi_backup" + ".sql";
tmestr = tmestr.Replace("/", "-");
tmestr = @"C:\db\" + tmestr;
StreamWriter file = new StreamWriter(tmestr);
ProcessStartInfo proc = new ProcessStartInfo();
string DBname = "olddb > \"" + tmestr + "\"";
string cmd = string.Format("-u {0} -p {1} -h {2} {3}","root","olddb","localhost",DBname);
proc.FileName = @"C:\Program Files\MySQL\MySQL Server 5.5\bin\mysqldump";
proc.RedirectStandardInput = true;
proc.RedirectStandardOutput = true;
proc.Arguments = cmd;
proc.UseShellExecute = false;
Process p = Process.Start(proc);
string res;
//MessageBox.Show();
res = p.StandardOutput.ReadToEnd();
MessageBox.Show("Eroaks : " + res);
file.WriteLine(res);
p.WaitForExit();
file.Close();
MessageBox.Show("Backup Completed" + cmd);



}
Reply With Quote
  #2 (permalink)  
Old 09-20-11, 04:28
it-iss.com it-iss.com is offline
Registered User
 
Join Date: Sep 2009
Location: San Sebastian, Spain
Posts: 620
You cannot have a space in between -p and the actual password. From the manual:

The password to use when connecting to the server. If you use the short option form (-p), you cannot have a space between the option and the password. If you omit the password value following the --password or -p option on the command line, mysqldump prompts for one.
__________________
Ronan Cashell
Senior Oracle/MySQL DBA
http://www.it-iss.com
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On