I'm attempting to restore MySQL database data from the dump file, using C# codes.

I'm suppose to complete the next command: mysql --verbose --user=root --password=qwerty123456 test < C:UsersDefaulttesting.SQL

I understand that C# does not recognise the "<" symbol and so i attempted a number of ways however it still didn't work. Can anybody assist me to with this particular? I wish to restore my database data back to MySQL using C# codes.

Thanks ahead of time.

            Process process = new Process();
            process.StartInfo.FileName = @"C:\Program Files\MySQL\MySQL Server 5.1\bin\mysql.exe";
            process.StartInfo.Arguments = @"--verbose --user=root --password=qwerty123456 test";
            process.StartInfo.UseShellExecute = false;
            process.StartInfo.RedirectStandardOutput = true;
            process.StartInfo.RedirectStandardInput = true;
            process.StartInfo.RedirectStandardError = true;
            process.StartInfo.CreateNoWindow = true;
            process.Start();

            StreamReader sr = process.StandardOutput;
            sr = File.OpenText(@"C:\Users\Default\testing.SQL");

The < handling should (IIRC) be OK should you simply set UseShellExecute = true.

However, if you want to prevent the spend professional, < is definitely an input - you ought to be writing the file to StandardInput. I'l most likely leave StandardOutput alone (set RedirectStandardOutput = false if you do not positively want the output).

Untested, but maybe:

        using(var stdin = process.StandardInput)
        using(var reader = File.OpenText(@"C:\Users\Default\testing.SQL")) {
            string line;
            while((line = reader.ReadLine()) != null) {
                stdin.WriteLine(line);
            }
            stdin.Close();
        }

(that ought to pipe within the file line by line)