MySqlConnector 2.5.0

About

MySqlConnector is a C# ADO.NET driver for MySQL, MariaDB, Amazon Aurora, Azure Database for MySQL and other MySQL-compatible databases.

More documentation is available at the MySqlConnector website.

How to Use

// set these values correctly for your database server
var builder = new MySqlConnectionStringBuilder
{
	Server = "your-server",
	UserID = "database-user",
	Password = "P@ssw0rd!",
	Database = "database-name",
};

// open a connection asynchronously
await using var connection = new MySqlConnection(builder.ConnectionString);
await connection.OpenAsync();

// create a DB command and set the SQL statement with parameters
await using var command = connection.CreateCommand();
command.CommandText = @"SELECT * FROM orders WHERE order_id = @OrderId;";
command.Parameters.AddWithValue("@OrderId", orderId);

// execute the command and read the results
await using var reader = await command.ExecuteReaderAsync();
while (reader.Read())
{
	var id = reader.GetInt32("order_id");
	var date = reader.GetDateTime("order_date");
	// ...
}

ASP.NET

For ASP.NET, use the MySqlConnector.DependencyInjection package to integrate with dependency injection and logging.

var builder = WebApplication.CreateBuilder(args);

// use AddMySqlDataSource to configure MySqlConnector
builder.Services.AddMySqlDataSource(builder.Configuration.GetConnectionString("Default"));

var app = builder.Build();

// use dependency injection to get a MySqlConnection in minimal APIs or in controllers
app.MapGet("/", async (MySqlConnection connection) =>
{
    // open and use the connection here
    await connection.OpenAsync();
    await using var command = connection.CreateCommand();
    command.CommandText = "SELECT name FROM users LIMIT 1";
    return "Hello World: " + await command.ExecuteScalarAsync();
});

app.Run();

Key Features

  • Full support for async I/O
  • High performance
  • Supports .NET Framework, .NET Core, and .NET 5.0+

Main Types

The main types provided by this library are:

  • MySqlConnection (implementation of DbConnection)
  • MySqlCommand (implementation of DbCommand)
  • MySqlDataReader (implementation of DbDataReader)
  • MySqlBulkCopy
  • MySqlBulkLoader
  • MySqlConnectionStringBuilder
  • MySqlConnectorFactory
  • MySqlDataAdapter
  • MySqlException
  • MySqlTransaction (implementation of DbTransaction)

Feedback

MySqlConnector is released as open source under the MIT license. Bug reports and contributions are welcome at the GitHub repository.

Showing the top 20 packages that depend on MySqlConnector.

Packages Downloads
Hangfire.MySqlStorage
Hangfire MySql Storage
56
Pomelo.EntityFrameworkCore.MySql
MySQL provider for Entity Framework Core
59
Pomelo.EntityFrameworkCore.MySql
Pomelo's MySQL database provider for Entity Framework Core.
54
Pomelo.EntityFrameworkCore.MySql
Pomelo's MySQL database provider for Entity Framework Core.
56
Pomelo.EntityFrameworkCore.MySql
Pomelo's MySQL database provider for Entity Framework Core.
58
Pomelo.EntityFrameworkCore.MySql
Pomelo's MySQL database provider for Entity Framework Core.
152
Pomelo.EntityFrameworkCore.MySql
Pomelo's MySQL database provider for Entity Framework Core.
161
Pomelo.EntityFrameworkCore.MySql
Pomelo's MySQL database provider for Entity Framework Core.
588
Pomelo.EntityFrameworkCore.MySql.Design
Package Description
53
Quantum.Framework.Core.StandardLib
Package Description
53
Quantum.Framework.Core.StandardLib
Package Description
54
Quantum.Framework.Core.StandardLib
Package Description
55
Quantum.Framework.Core.StandardLib
Package Description
58
Quantum.Framework.Core.StandardLib
Package Description
62
Quantum.Framework.Core.StandardLib
Package Description
71
Quantum.Framework.Core.StandardLib
Package Description
74
Quantum.Framework.Core.StandardLib
Package Description
75
Quantum.Framework.Core.StandardLib
Package Description
77
SqlSugarCore
好用的ORM框架 .Net Core .Net5 .Net6 .Net7 安装此版本,支持国外主流和国产人大金仓达梦 QuestDb ClickHouse Oracle MySql SqlServer Sqlite, 版本说明: 5.0.3.5-Max 最低要求.Net Core 3.0+ ,5.0.0-5.0.3.4 最低要求 .Net Core 2.0+ SqlSugar ORM ,High-performance, lightweight
56

https://mysqlconnector.net/overview/version-history/

.NET Framework 4.6.2

.NET Standard 2.1

.NET Standard 2.0

.NET 10.0

.NET 9.0

.NET 8.0

.NET 6.0

.NET Framework 4.7.1

.NET Framework 4.8

Version Downloads Last updated
2.5.0 21 11/13/2025
2.5.0-beta.1 20 10/30/2025
2.4.0 81 11/14/2024
2.4.0-beta.2 39 11/09/2024
2.4.0-beta.1 43 11/16/2024
2.3.7 109 04/28/2024
2.3.6 49 05/01/2024
2.3.5 265 05/06/2024
2.3.4 39 12/02/2024
2.3.3 31 11/24/2024
2.3.2 43 11/28/2024
2.3.1 45 11/29/2024
2.3.0 42 12/04/2024
2.3.0-beta.2 36 08/04/2023
2.3.0-beta.1 41 04/14/2023
2.2.7 31 12/06/2024
2.2.6 39 12/06/2024
2.2.5 143 05/24/2024
2.2.4 40 11/12/2024
2.2.3 38 10/31/2024
2.2.2 38 04/28/2024
2.2.1 45 11/27/2024
2.2.0 39 11/29/2024
2.1.13 53 05/22/2024
2.1.12 42 11/19/2024
2.1.11 50 11/27/2024
2.1.10 36 11/27/2024
2.1.9 39 11/26/2024
2.1.7 40 11/23/2024
2.1.5 34 11/28/2024
2.1.1 45 04/21/2022
1.3.14 34 11/26/2024
1.3.13 49 07/15/2022
1.3.12 38 11/28/2024
1.3.9 42 11/27/2024
1.3.5 42 11/27/2024
1.3.4 43 12/02/2024
1.3.3 43 04/21/2022
1.3.2 41 11/26/2024
1.3.1 36 11/11/2024
0.69.10 13,733 04/25/2022
0.69.9 62 04/27/2022
0.69.8 29 11/27/2024
0.69.7 42 12/02/2024
0.69.6 36 11/27/2024
0.69.5 32 11/12/2024
0.69.4 32 11/12/2024
0.69.1 36 12/08/2024
0.69.0 41 11/28/2024
0.68.1 41 11/27/2024
0.67.0 35 12/10/2024
0.66.0 37 11/12/2024
0.64.2 39 11/14/2024
0.64.1 41 04/21/2022
0.63.2 29 11/12/2024
0.60.4 37 11/26/2024
0.60.1 33 11/12/2024
0.60.0 36 12/06/2024
0.59.1 33 11/28/2024
0.59.0 33 11/27/2024
0.58.0 37 11/12/2024
0.57.0 38 12/06/2024
0.56.0 33 11/01/2024
0.55.0 32 12/17/2024
0.52.0 32 12/10/2024
0.51.1 36 11/28/2024
0.50.0 31 11/27/2024
0.49.3 37 11/28/2024
0.49.0 35 11/27/2024
0.48.2 38 12/04/2024
0.48.1 38 11/12/2024
0.48.0 31 11/12/2024
0.47.0 41 11/27/2024
0.46.2 33 11/27/2024
0.46.1 31 12/14/2024
0.46.0 41 11/12/2024
0.45.0 41 11/27/2024
0.44.1 32 11/25/2024
0.44.0 40 12/06/2024
0.42.3 36 11/12/2024
0.42.2 40 12/06/2024
0.42.1 35 11/12/2024
0.42.0 36 11/11/2024
0.41.0 35 11/26/2024
0.40.3 36 11/27/2024
0.40.2 32 11/27/2024
0.36.0 34 12/05/2024
0.35.0 32 11/12/2024
0.32.0 34 11/27/2024
0.30.0 40 11/28/2024
0.29.4 30 11/28/2024
0.29.2 34 04/21/2022
0.26.4 33 11/12/2024
0.26.2 31 11/27/2024
0.26.1 31 11/12/2024
0.25.0 40 11/28/2024
0.20.0 35 11/27/2024
0.19.3 33 11/29/2024
0.16.2 28 12/02/2024
0.9.0 29 12/11/2024
0.7.4 29 11/29/2024
0.7.0 39 11/27/2024
0.6.0 30 11/30/2024
0.5.0 38 12/01/2024
0.2.1 36 05/02/2024
0.2.0 43 05/31/2024