Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/294.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# mysqldump.exe未对mysql数据库进行完全备份_C#_Mysql_Database Backups - Fatal编程技术网

C# mysqldump.exe未对mysql数据库进行完全备份

C# mysqldump.exe未对mysql数据库进行完全备份,c#,mysql,database-backups,C#,Mysql,Database Backups,我有一个备份MySQL数据库的过程,而且我有不同的MySQL服务器。此过程适用于某些MySQL服务器。但在某些服务器上,它无法正常工作,无法创建1kb大小的备份文件 代码 谁能告诉我问题出在哪里,我该如何解决它。备份语句在哪里 以下是备份数据库的最佳方法: private void BackupDatabase() { string time = DateTime.Now.ToString("dd-MM-yyyy"); string

我有一个备份MySQL数据库的过程,而且我有不同的MySQL服务器。此过程适用于某些MySQL服务器。但在某些服务器上,它无法正常工作,无法创建1kb大小的备份文件

代码
谁能告诉我问题出在哪里,我该如何解决它。

备份语句在哪里

以下是备份数据库的最佳方法:

private void BackupDatabase()
        {
            string time = DateTime.Now.ToString("dd-MM-yyyy");
            string savePath = AppDomain.CurrentDomain.BaseDirectory + @"Backups\"+time+"_"+saveFileDialogBackUp.FileName;
            if (saveFileDialogBackUp.ShowDialog() == DialogResult.OK)
            {
                try {
                        using (Process mySqlDump = new Process())
                        {
                            mySqlDump.StartInfo.FileName = @"mysqldump.exe";
                            mySqlDump.StartInfo.UseShellExecute = false;
                            mySqlDump.StartInfo.Arguments = @"-u" + user + " -p" + pwd + " -h" + server + " " + database + " -r \"" + savePath + "\"";
                            mySqlDump.StartInfo.RedirectStandardInput = false;
                            mySqlDump.StartInfo.RedirectStandardOutput = false;
                            mySqlDump.StartInfo.CreateNoWindow = true;
                            mySqlDump.Start();
                            mySqlDump.WaitForExit();
                            mySqlDump.Close();
                        }
                    }
                    catch (IOException ex)
                    {
                        MessageBox.Show("Connot backup database! \n\n" + ex);
                    }
                MessageBox.Show("Done! database backuped!", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
祝你好运

我终于得到了答案。 我们需要在MySQL用户或数据库上选择并锁定表权限,以便备份。
在数据库上设置这些权限后,我可以对该数据库进行完全备份。

异常说明了什么?没有任何异常。它创建的备份文件没有数据。文件大小为1KB。您确定吗?你捕获了一些但从未对它们做过任何事情仍然是相同的问题,它在某些服务器上工作,在某些MySQL服务器上不工作。它创建了一个sql文件,其中包含一些注释行,而没有任何内容。MySQL服务器的配置是否有任何问题。最后我得到了答案。我们需要在MySQL用户或数据库上选择并锁定表权限,以便备份。在数据库上设置这些权限后,我可以对该数据库进行完整备份。但它并没有提供所有数据
private void BackupDatabase()
        {
            string time = DateTime.Now.ToString("dd-MM-yyyy");
            string savePath = AppDomain.CurrentDomain.BaseDirectory + @"Backups\"+time+"_"+saveFileDialogBackUp.FileName;
            if (saveFileDialogBackUp.ShowDialog() == DialogResult.OK)
            {
                try {
                        using (Process mySqlDump = new Process())
                        {
                            mySqlDump.StartInfo.FileName = @"mysqldump.exe";
                            mySqlDump.StartInfo.UseShellExecute = false;
                            mySqlDump.StartInfo.Arguments = @"-u" + user + " -p" + pwd + " -h" + server + " " + database + " -r \"" + savePath + "\"";
                            mySqlDump.StartInfo.RedirectStandardInput = false;
                            mySqlDump.StartInfo.RedirectStandardOutput = false;
                            mySqlDump.StartInfo.CreateNoWindow = true;
                            mySqlDump.Start();
                            mySqlDump.WaitForExit();
                            mySqlDump.Close();
                        }
                    }
                    catch (IOException ex)
                    {
                        MessageBox.Show("Connot backup database! \n\n" + ex);
                    }
                MessageBox.Show("Done! database backuped!", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }