Results 1 to 2 of 2

Thread: back up

  1. #1
    Join Date
    Sep 2011
    Posts
    1

    Unanswered: 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);



    }

  2. #2
    Join Date
    Sep 2009
    Location
    San Sebastian, Spain
    Posts
    880
    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
    Certified Oracle DBA/Certified MySQL Expert (DBA & Cluster DBA)
    http://www.it-iss.com
    Follow me on Twitter

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •