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
WillowMedia.Orm.MySql
Package Description
111
WillowMedia.Orm.MySql
Package Description
109
WillowMedia.Orm.MySql
Package Description
83
WillowMedia.Orm.MySql
Package Description
82
WillowMedia.Orm.MySql
Package Description
81
WillowMedia.Orm.MySql
Package Description
73
WillowMedia.Orm.MySql
Package Description
68
WillowMedia.Orm.MySql
Package Description
52
WillowMedia.Orm.MySql
Package Description
41
WillowMedia.Orm.MySql
Package Description
40
WillowMedia.Orm.MySql
Package Description
39
WillowMedia.Orm.MySql
Package Description
33
WillowMedia.Orm.MySql
Package Description
29
WillowMedia.Orm.MySql
Package Description
28
WillowMedia.Orm.MySql
Package Description
23
WillowMedia.Orm.MySql
Package Description
13
WillowMedia.Orm.MySql
Package Description
10
WillowMedia.Orm.MySql
Package Description
8

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 91 11/26/2025
2.5.0-beta.1 4 11/04/2025
2.4.0 270 05/29/2025
2.4.0-beta.2 7 06/28/2025
2.4.0-beta.1 7 06/28/2025
2.3.7 7 06/28/2025
2.3.6 7 06/28/2025
2.3.5 7 06/28/2025
2.3.4 7 06/28/2025
2.3.3 7 06/28/2025
2.3.2 7 06/28/2025
2.3.1 7 06/28/2025
2.3.0 7 06/28/2025
2.2.7 7 06/28/2025
2.2.6 7 06/28/2025
2.2.5 7 06/28/2025
2.2.4 6 06/28/2025
2.2.3 7 06/28/2025
2.2.2 9 06/28/2025
2.2.1 7 06/28/2025
2.2.0 8 06/28/2025
2.1.13 7 06/28/2025
2.1.12 7 06/28/2025
2.1.11 7 06/28/2025
2.1.10 7 06/28/2025
2.1.9 8 06/28/2025
2.1.8 8 06/28/2025
2.1.7 8 06/28/2025
2.1.6 7 06/28/2025
2.1.5 7 06/28/2025
2.1.4 7 06/28/2025
2.1.3 7 06/28/2025
2.1.2 7 06/28/2025
2.1.1 7 06/28/2025
2.1.0 7 06/28/2025
2.0.0 8 06/28/2025
1.3.14 5 06/28/2025
1.3.13 8 06/28/2025
1.3.12 8 06/28/2025
1.3.11 7 06/28/2025
1.3.10 7 06/28/2025
1.3.9 8 06/28/2025
1.3.8 7 06/28/2025
1.3.7 7 06/28/2025
1.3.6 7 06/28/2025
1.3.5 7 06/28/2025
1.3.4 7 06/28/2025
1.3.3 7 06/28/2025
1.3.2 9 06/28/2025
1.3.1 7 06/28/2025
1.3.0 7 06/28/2025
1.2.1 7 06/28/2025
1.2.0 7 06/28/2025
1.1.0 7 06/28/2025
1.0.1 8 06/28/2025
1.0.0 7 06/28/2025
0.69.10 7 06/28/2025
0.69.9 7 06/28/2025
0.69.8 7 06/28/2025
0.69.7 7 06/28/2025
0.69.6 7 06/28/2025
0.69.5 7 06/28/2025
0.69.4 7 06/28/2025
0.69.3 7 06/28/2025
0.69.2 7 06/28/2025
0.69.1 7 06/28/2025
0.69.0 7 06/28/2025
0.68.1 8 06/28/2025
0.68.0 7 06/28/2025
0.67.0 7 06/28/2025
0.66.0 7 06/28/2025
0.65.0 7 06/28/2025
0.64.2 7 06/28/2025
0.64.1 7 06/28/2025
0.64.0 7 06/28/2025
0.63.2 7 06/28/2025
0.63.1 7 06/28/2025
0.63.0 8 06/28/2025
0.62.0 7 06/28/2025
0.61.0 8 06/28/2025
0.60.4 7 06/28/2025
0.60.3 8 06/28/2025
0.60.2 7 06/28/2025
0.60.1 7 06/28/2025
0.60.0 7 06/28/2025
0.59.2 7 06/28/2025
0.59.1 7 06/28/2025
0.59.0 7 06/28/2025
0.58.0 7 06/28/2025
0.57.0 7 06/28/2025
0.56.0 7 06/28/2025
0.55.0 7 06/28/2025
0.54.0 7 06/28/2025
0.53.0 8 06/28/2025
0.52.0 7 06/28/2025
0.51.1 7 06/28/2025
0.51.0 7 06/28/2025
0.50.0 8 06/28/2025
0.49.3 7 06/28/2025
0.49.2 7 06/28/2025
0.49.0 7 06/28/2025
0.48.2 7 06/28/2025
0.48.1 7 06/28/2025
0.48.0 7 06/28/2025
0.47.1 7 06/28/2025
0.47.0 7 06/28/2025
0.46.2 8 06/28/2025
0.46.1 7 06/28/2025
0.46.0 7 06/28/2025
0.45.1 7 06/28/2025
0.45.0 7 06/28/2025
0.44.1 7 06/28/2025
0.44.0 7 06/28/2025
0.43.0 7 06/28/2025
0.42.3 7 06/28/2025
0.42.2 7 06/28/2025
0.42.1 7 06/28/2025
0.42.0 7 06/28/2025
0.41.0 8 06/28/2025
0.40.4 7 06/28/2025
0.40.3 7 06/28/2025
0.40.2 7 06/28/2025
0.36.0 7 06/28/2025
0.35.0 7 06/28/2025
0.32.0 7 06/28/2025
0.30.0 7 06/28/2025
0.29.4 7 06/28/2025
0.29.2 7 06/28/2025
0.26.5 8 06/28/2025
0.26.4 7 06/28/2025
0.26.3 7 06/28/2025
0.26.2 7 06/28/2025
0.26.1 7 06/28/2025
0.26.0 7 06/28/2025
0.25.1 7 06/28/2025
0.25.0 7 06/28/2025
0.20.0 7 06/28/2025
0.19.5 7 06/28/2025
0.19.4 7 06/28/2025
0.19.3 8 06/28/2025
0.19.2 7 06/28/2025
0.16.2 7 06/28/2025
0.10.0 7 06/28/2025
0.9.0 7 06/28/2025
0.8.0 7 06/28/2025
0.7.4 8 06/28/2025
0.7.3 7 06/28/2025
0.7.2 7 06/28/2025
0.7.1 7 06/28/2025
0.7.0 7 06/28/2025
0.6.2 7 06/28/2025
0.6.1 7 06/28/2025
0.6.0 7 06/28/2025
0.5.0 7 06/28/2025
0.4.0 7 06/28/2025
0.3.0 7 06/28/2025
0.2.1 7 06/28/2025
0.2.0 7 06/28/2025
0.1.0 8 06/28/2025