DateTime backupTime = DateTime.Now; int year = backupTime.Year; int month = backupTime.Month; int day = backupTime.Day; int hour = backupTime.Hour; int minute = backupTime.Minute; int second = backupTime.Second; int ms = backupTime.Millisecond; String tmestr = backupTime.ToString(); tmestr = "C:\\" + year + "-" + month + "-" + day + "-" + hour + "-" + minute + ".sql"; StreamWriter file = new StreamWriter(tmestr); ProcessStartInfo proc = new ProcessStartInfo(); string cmd = string.Format(@"-u {0} -p {1} -h {2} {3} > {4};", "root", "", "localhost", "globasys", "backup.sql"); proc.FileName = @"C:\Program Files\MySQL\MySQL Server 6.0\bin\mysqldump"; proc.RedirectStandardInput = false; proc.RedirectStandardOutput = true; proc.Arguments = cmd;//"-u root -p smartdb > testdb.sql"; proc.UseShellExecute = false; Process p = Process.Start(proc); string res; res = p.StandardOutput.ReadToEnd(); file.WriteLine(res); p.WaitForExit(); file.Close();
Query: /*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT *//*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */ Error occured at:2011-10-17 15:23:28 Line no.:8 Error Code: 1064 - 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 'SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */' at line 1 Query: /*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT *//*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */ Error occured at:2011-10-18 15:33:23 Line no.:8 Error Code: 1064 - 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 'SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */' at line 1 Query: /*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT *//*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */ Error occured at:2011-10-18 15:34:56 Line no.:8 Error Code: 1064 - 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 'SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */' at line 1
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)