MySqlBackup.NET
2.6.3
dotnet add package MySqlBackup.NET --version 2.6.3
NuGet\Install-Package MySqlBackup.NET -Version 2.6.3
<PackageReference Include="MySqlBackup.NET" Version="2.6.3" />
<PackageVersion Include="MySqlBackup.NET" Version="2.6.3" />
<PackageReference Include="MySqlBackup.NET" />
paket add MySqlBackup.NET --version 2.6.3
#r "nuget: MySqlBackup.NET, 2.6.3"
#addin nuget:?package=MySqlBackup.NET&version=2.6.3
#tool nuget:?package=MySqlBackup.NET&version=2.6.3
MySqlBackup.NET
A versatile tool for backing up and restoring MySQL databases in C#, VB.NET, and ASP.NET.
Latest Release: v2.6.3 (July 13th, 2025)
Change Log
Overview
MySqlBackup.NET is a .NET library (DLL) designed to backup and restore MySQL databases. Compatible with multiple MySQL connectors—MySql.Data.DLL
, MySqlConnector.DLL
, and Devart.Express.MySql.DLL
—it offers a programmatic alternative to tools like MySqlDump, providing greater control and flexibility in .NET environments.
Developed in C#, this library supports any .NET language (e.g., VB.NET, F#) and excels in scenarios where MySqlDump.exe or MySQL Workbench are impractical, such as web-based applications (ASP.NET) or end-user tools with simplified interfaces.
Key Features
- Backup and restore MySQL databases programmatically.
- Supports all .NET languages.
- Export/import via files or
MemoryStream
. - Conditional row exports (filter tables/rows).
- Progress reporting for export and import tasks.
- Flexible row export modes:
INSERT
,INSERT IGNORE
,REPLACE
,ON DUPLICATE KEY UPDATE
,UPDATE
. - Ideal for ASP.NET and web service integration.
Getting Started
Installation
Download
Grab the latest release from: GitHub Releases
NuGet Packages
Install via NuGet Package Manager:
MySqlConnector:
PM> Install-Package MySqlBackup.NET.MySqlConnector
https://www.nuget.org/packages/MySqlBackup.NET.MySqlConnector/MySql.Data Connector:
PM> Install-Package MySqlBackup.NET
https://www.nuget.org/packages/MySqlBackup.NET/Devart Express Connector:
PM> Install-Package MySqlBackup.Net.DevartExpress
https://www.nuget.org/packages/MySqlBackup.Net.DevartExpress/
Add to Your Project
See the detailed guide:
How to Add This Library into Your Project
Basic Usage
Backup a Database
string constr = "server=localhost;user=root;pwd=1234;database=test1;convertzerodatetime=true;";
string filePath = @"C:\backup.sql";
using (var conn = new MySqlConnection(constr))
using (var cmd = conn.CreateCommand())
using (var mb = new MySqlBackup(cmd))
{
conn.Open();
mb.ExportToFile(filePath);
}
Restore a Database
string constr = "server=localhost;user=root;pwd=1234;database=test1;convertzerodatetime=true;";
string filePath = @"C:\backup.sql";
using (var conn = new MySqlConnection(constr))
using (var cmd = conn.CreateCommand())
using (var mb = new MySqlBackup(cmd))
{
conn.Open();
mb.ImportFromFile(filePath);
}
Why MySqlBackup.NET?
Unlike MySQL Workbench (developer-focused) or MySqlDump.exe (restricted in web environments), MySqlBackup.NET offers:
- End-User Simplicity: Preset parameters for a one-click backup experience.
- Web Compatibility: Runs seamlessly in ASP.NET, bypassing hosting restrictions on executables.
- Programmatic Control: Fine-tuned output handling within .NET.
Dependencies
MySqlBackup.NET requires one of these MySQL connectors:
Connector | Source | License | DLLs |
---|---|---|---|
MySqlConnector | MySqlConnector | MIT | MySqlConnector.dll |
MySql.Data | MySQL Connector/Net | GPL | MySql.Data.dll |
Devart Express | dotConnect for MySQL | Custom (FAQ) | Devart.Data.dll , Devart.Data.MySql.dll |
Compatibility
We aim for MySqlBackup.NET to achieve 100% SQL compliance, ensuring seamless compatibility with mysqldump
and mysql.exe
for both backup and restore operations. Version 2.6 introduces key improvements, addressing some flaws in previous version and compatibility challenges with mysqldump
-generated files. If you encounter any incompatibilities, we welcome feedback via GitHub Issues to help us refine and uphold this goal.
Configuration Tips
Unicode Support
- Always use the default character set of
utf8mb4
, orutf8
in older MySQL versions that do not supportutf8mb4
. - It is recommended to use
convertzerodatetime=true
in the connection string for compatibility when handling null datetime values.
Performance Benchmark
For a 416 MB database (400,000 rows, 4 tables, InnoDB) on an Intel Core i7-4770S (3.10GHz, 16GB RAM, SSD Samsung 870 Evo 500GB):
Task | Tool | Avg. Time | File Size |
---|---|---|---|
Backup | MySqlBackup.NET (Parallel) | ~10.21s | 571.588 MB |
Backup | MySqlBackup.NET (Single) | ~15.72s | 571.588 MB |
Backup | mysqldump.exe | ~6.76s | 566.976 MB |
Restore | MySqlBackup.NET | ~35.87s | - |
Restore | mysql.exe | ~32.76s | - |
MySqlBackup.NET v2.6 offers competitive performance, especially in parallel mode, with significant improvements over previous versions. Full details: Performance Benchmark Wiki.
License
MySqlBackup.NET is released under The Unlicense, making it free for any use.
Conclusion
MySqlBackup.NET empowers developers and end-users alike with a robust, .NET-native solution for MySQL database management. Whether for desktop apps, web services, or automated backups, it’s a versatile addition to your toolkit, built by a global community for a global community.
Explore more on GitHub!
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 is compatible. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
.NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard2.0 is compatible. netstandard2.1 is compatible. |
.NET Framework | net461 was computed. net462 is compatible. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 is compatible. net481 was computed. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen40 was computed. tizen60 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETFramework 4.6.2
- MySql.Data (>= 9.3.0)
-
.NETFramework 4.8
- MySql.Data (>= 9.3.0)
-
.NETStandard 2.0
- MySql.Data (>= 9.3.0)
- NETStandard.Library (>= 2.0.3)
-
.NETStandard 2.1
- MySql.Data (>= 9.3.0)
-
net8.0
- MySql.Data (>= 9.3.0)
-
net9.0
- MySql.Data (>= 9.3.0)
NuGet packages (15)
Showing the top 5 NuGet packages that depend on MySqlBackup.NET:
Package | Downloads |
---|---|
Nascorp.Library
Library to methods utilities |
|
ThrowawayDb.MySql
Dead simple integration tests with Sql server throwaway databases. |
|
FrontLookCoreDbBackUpLibrary
This package adds an asp.net core database backup library! Supports MsSql And MySql. |
|
Senparc.Ncf.Database.MySql.Backup
Senparc.Ncf.Database.MySql.Backup |
|
MyDapper
Dapper的操作帮助类 |
GitHub repositories (5)
Showing the top 5 popular GitHub repositories that depend on MySqlBackup.NET:
Repository | Stars |
---|---|
revenz/FileFlows
FileFlows is a file processing application that can execute actions against a file in a tree flow structure.
|
|
feiyit/FytSoaCms
NetCore2.2开发, Vs2017 数据Mysql
|
|
jaskie/PlayoutAutomation
Television broadcast automation system
|
|
logicpulse/logicPOS
Logicpulse's Open Source POS System
|
|
Zaid-Ajaj/ThrowawayDb
Dead simple integration tests with SQL Server or Postgres throwaway databases that are created on the fly, used briefly then disposed of automagically.
|
Version | Downloads | Last Updated |
---|---|---|
2.6.3 | 0 | 7/13/2025 |
2.6.2 | 89 | 7/11/2025 |
2.6.1 | 207 | 7/4/2025 |
2.6.0 | 138 | 7/4/2025 |
2.3.9 | 8,976 | 3/12/2025 |
2.3.8 | 127,824 | 3/7/2023 |
2.3.7 | 104,802 | 10/18/2022 |
2.3.6.1 | 155,892 | 10/20/2021 |
2.3.6 | 4,540 | 10/17/2021 |
2.3.5.3 | 4,320 | 9/24/2021 |
2.3.5.2 | 1,510 | 9/23/2021 |
2.3.5.1 | 1,588 | 9/22/2021 |
2.3.4.2 | 9,173 | 7/30/2021 |
2.3.4.1 | 6,397 | 7/12/2021 |
2.3.4 | 90,085 | 3/10/2021 |
2.3.3.1 | 45,679 | 7/16/2020 |
2.3.1 | 326,060 | 8/23/2019 |
2.3.0.1 | 10,095 | 7/26/2019 |
2.3.0 | 5,253 | 6/24/2019 |
2.2.1 | 16,381 | 4/7/2019 |
2.2.0 | 1,989 | 4/7/2019 |
2.1.0 | 15,210 | 12/1/2018 |
2.0.12.1 | 10,930 | 8/28/2018 |
2.0.12 | 26,064 | 3/26/2018 |
2.0.11.1 | 6,029 | 2/7/2018 |
2.0.11 | 2,677 | 2/7/2018 |
2.0.10.1 | 5,364 | 12/2/2017 |
2.0.10 | 4,339 | 12/1/2017 |
2.0.9.5 | 54,219 | 11/19/2016 |
2.0.9.4 | 8,627 | 3/20/2016 |
2.0.9.3 | 9,631 | 1/9/2016 |
2.0.9.2 | 6,743 | 8/8/2015 |
2.0.9.1 | 3,005 | 7/24/2015 |
2.0.9 | 2,814 | 7/19/2015 |
2.0.8 | 37,211 | 2/24/2015 |
2.0.7.1 | 18,342 | 1/26/2015 |
2.0.6 | 3,188 | 11/21/2014 |
2.0.5.1 | 2,833 | 10/20/2014 |
2.0.5 | 2,521 | 10/20/2014 |
2.0.4 | 4,219 | 5/12/2014 |
2.0.3 | 2,638 | 5/11/2014 |
2.0.2.1 | 3,439 | 4/10/2014 |