0

我试图使用 mysqlbackup dll 获取 mysql 备份。文件已创建但 sql 未备份,上述问题是在 bkp.ExportToFile 代码中抛出的。我正在使用以下查询,请帮助解决这个问题,在此先感谢!

try{

string connectionString = $"server={ serverName };user={ userName };password={ password };persistsecurityinfo=True;database={ databaseName };SslMode=none;Convert Zero Datetime=true;";

using (con= new MySqlConnection(connString))
{
    filename = "Bkp_20181101.sql";

    using (MySqlCommand command = new MySqlCommand())
    {
        command.Connection = connection;
        OpenConnection();

        using (MySqlBackup bkp = new MySqlBackup(command))
        {
            try
            {
                bkp.ExportToFile( "D:\\" + filename);
            }
            catch (MySqlException ex)
            {
                CloseConnection();
                throw ex;
            }
        }
        CloseConnection();
    }
}
4

0 回答 0