0
코드에 오류가 없습니다. 하지만 내가 백업 할 때 파일의 크기는 0kb 또는 1kb뿐입니다. 그리고 나는 아무것도 복원하지 않습니다. 모든 데이터는 계속 삭제됩니다.mySQL 백업 및 복원 C#
string path;
path = "D:\\MySqlBackup"+ ".sql";
StreamWriter file = new StreamWriter(path);
ProcessStartInfo psi = new ProcessStartInfo();
psi.FileName ="C:\\xampp\\mysql\\bin\\mysqldump.exe";
psi.RedirectStandardInput = false;
psi.RedirectStandardOutput = true;
psi.Arguments = "--user=root --password=database --database=hotelreservationandbillingsystem < D:\\MySqlBackup.sql";
psi.UseShellExecute = false;
Process process = Process.Start(psi);
string output;
output = process.StandardOutput.ReadToEnd();
file.WriteLine(output);
process.WaitForExit();
file.Close();
process.Close();
MessageBox.Show("Back Up Successfully!","Saved",MessageBoxButtons.OKCancel,MessageBoxIcon.Information);
코드 복원 위로 코드까지
string path;
path = "D:\\MySqlBackup.sql";
StreamReader file = new StreamReader(path);
string input = file.ReadToEnd();
file.Close();
ProcessStartInfo psi = new ProcessStartInfo();
psi.FileName = "C:\\xampp\\mysql\\bin\\mysqldump.exe";
psi.RedirectStandardInput = true;
psi.RedirectStandardOutput = false;
psi.Arguments = "--user=root --password=database --database=hotelreservationandbillingsystem < D:\\MySqlBackup.sql";
psi.UseShellExecute = false;
Process process = Process.Start(psi);
process.StandardInput.WriteLine(input);
process.StandardInput.Close();
process.WaitForExit();
process.Close();
MessageBox.Show("Restored Successfully!", "Restored", MessageBoxButtons.OKCancel, MessageBoxIcon.Information);
복원인가? MySqlBackup을 위해? – Frank
예, 필요 전제 조건 MySqlBackup.NET은 다음 구성 요소를 사용하여 작동합니다. MySQL 닷넷 커넥터/Net (MySql.Data.DLL) MySqlBackup.NET이 작동하려면이 DLL에 대한 참조를 프로젝트에 추가해야합니다. MySql.Data.DLL은 Oracle Corporation에서 개발되었으며 GPL 라이센스 (http://www.gnu.org/licenses/old-licenses/gpl-2.0.html)로 라이센스가 부여됩니다. –