MySqlConnector 2.3.7

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
using var connection = new MySqlConnection(builder.ConnectionString);
await connection.OpenAsync();

// create a DB command and set the SQL statement with parameters
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
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
Pomelo.EntityFrameworkCore.MySql
Pomelo's MySQL database provider for Entity Framework Core.
3,460
Pomelo.EntityFrameworkCore.MySql
Pomelo's MySQL database provider for Entity Framework Core.
1,371
Pomelo.EntityFrameworkCore.MySql
Pomelo's MySQL database provider for Entity Framework Core.
1,001
Pomelo.EntityFrameworkCore.MySql
Pomelo's MySQL database provider for Entity Framework Core.
931
Pomelo.EntityFrameworkCore.MySql
Pomelo's MySQL database provider for Entity Framework Core.
770
Pomelo.EntityFrameworkCore.MySql
Pomelo's MySQL database provider for Entity Framework Core.
48
Pomelo.EntityFrameworkCore.MySql
MySQL provider for Entity Framework Core
40
Pomelo.EntityFrameworkCore.MySql
Pomelo's MySQL database provider for Entity Framework Core.
33
Pomelo.EntityFrameworkCore.MySql
MySQL provider for Entity Framework Core
27
Pomelo.EntityFrameworkCore.MySql
Pomelo's MySQL database provider for Entity Framework Core.
23
Pomelo.EntityFrameworkCore.MySql
Package Description
21
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
21
SqlSugarCore
好用的ORM框架 .Net Core .Net5 .Net6 .Net7 安装此版本,支持国外主流和国产人大金仓达梦, 版本说明: 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
21
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
20
SqlSugarCore
好用的ORM框架 .Net Core .Net3.1 .Net7 .Net8 安装此版本,支持国外主流和国产人大金仓达梦 OceanBase GaussDB 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
20
SqlSugarCore
.Net Core3.1 .Net5 .Net6 .Net7 .Net8 安装此版本,好用的ORM框架 ,支持国外主流和国产人大金仓达梦 OceanBase GaussDB 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
19
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
19

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

Version Downloads Last updated
2.4.0-beta.2 1 10/20/2024
2.4.0-beta.1 1 10/16/2024
2.3.7 9 04/27/2024
2.3.6 7 03/23/2024
2.3.5 12 02/01/2024
2.3.4 8 02/01/2024
2.3.3 13 12/30/2023
2.3.2 9 12/30/2023
2.3.1 856 11/24/2023
2.3.0 8 12/07/2023
2.3.0-beta.4 8 01/05/2024
2.3.0-beta.3 12 10/04/2023
2.3.0-beta.2 10 10/04/2023
2.3.0-beta.1 9 06/30/2023
2.2.7 10 12/07/2023
2.2.6 14 08/27/2023
2.2.5 35 06/25/2023
2.2.4 12 10/16/2023
2.2.3 13 06/19/2023
2.2.2 11 10/15/2023
2.2.1 12 08/23/2023
2.2.0 9 10/16/2023
2.1.13 10 11/01/2023
2.1.12 9 11/02/2023
2.1.11 18 10/25/2023
2.1.10 17 10/26/2023
2.1.9 11 07/02/2023
2.1.8 11 08/17/2023
2.1.7 13 10/15/2023
2.1.6 9 10/16/2023
2.1.5 12 10/16/2023
2.1.4 12 06/19/2023
2.1.3 9 10/15/2023
2.1.2 3,430 06/16/2022
2.1.1 11 10/15/2023
2.1.0 11 07/01/2023
2.0.0 1,347 11/12/2021
1.3.14 9 11/01/2023
1.3.13 9 11/01/2023
1.3.12 12 06/30/2023
1.3.11 12 07/01/2023
1.3.10 11 11/02/2023
1.3.9 11 10/12/2023
1.3.8 12 10/16/2023
1.3.7 938 05/24/2021
1.3.6 12 10/15/2023
1.3.5 9 06/21/2023
1.3.4 10 10/16/2023
1.3.3 16 06/20/2023
1.3.2 10 10/13/2023
1.3.1 9 10/16/2023
1.3.0 9 06/20/2023
1.2.1 9 10/16/2023
1.2.0 9 10/16/2023
1.1.0 773 12/16/2020
1.0.1 11 10/16/2023
1.0.0 9 06/19/2023
0.69.10 6 10/29/2023
0.69.9 41 12/16/2020
0.69.8 11 10/26/2023
0.69.7 10 06/19/2023
0.69.6 9 11/02/2023
0.69.5 10 10/17/2023
0.69.4 9 11/02/2023
0.69.3 11 10/26/2023
0.69.2 7 10/26/2023
0.69.1 10 10/26/2023
0.69.0 8 10/26/2023
0.68.1 8 10/26/2023
0.68.0 11 10/26/2023
0.67.0 8 10/26/2023
0.66.0 10 10/13/2023
0.65.0 9 10/12/2023
0.64.2 8 10/26/2023
0.64.1 10 11/02/2023
0.64.0 8 11/01/2023
0.63.2 9 11/01/2023
0.63.1 9 10/26/2023
0.63.0 9 11/02/2023
0.62.0 9 11/02/2023
0.61.0 23 04/09/2021
0.60.4 11 11/01/2023
0.60.3 9 11/01/2023
0.60.2 12 11/02/2023
0.60.1 10 10/26/2023
0.60.0 12 11/01/2023
0.59.2 7 11/01/2023
0.59.1 10 10/26/2023
0.59.0 8 10/15/2023
0.58.0 9 11/02/2023
0.57.0 9 11/02/2023
0.56.0 7 10/26/2023
0.55.0 10 10/22/2023
0.54.0 11 11/01/2023
0.53.0 11 10/26/2023
0.52.0 13 10/10/2023
0.51.1 10 11/01/2023
0.51.0 10 11/02/2023
0.50.0 13 10/14/2023
0.49.3 12 10/26/2023
0.49.2 32 01/18/2021
0.49.0 8 10/26/2023
0.48.2 9 11/01/2023
0.48.1 10 10/26/2023
0.48.0 8 10/23/2023
0.47.1 10 11/02/2023
0.47.0 8 10/26/2023
0.46.2 9 11/01/2023
0.46.1 11 11/02/2023
0.46.0 8 11/02/2023
0.45.1 8 10/13/2023
0.45.0 8 10/26/2023
0.44.1 13 10/26/2023
0.44.0 12 10/17/2023
0.43.0 10 11/02/2023
0.42.3 10 11/02/2023
0.42.2 7 10/26/2023
0.42.1 8 11/02/2023
0.42.0 10 10/26/2023
0.41.0 11 10/26/2023
0.40.4 10 10/26/2023
0.40.3 13 10/26/2023
0.40.2 9 10/26/2023
0.36.0 8 11/02/2023
0.35.0 9 11/02/2023
0.32.0 10 10/26/2023
0.30.0 10 10/20/2023
0.29.4 9 11/02/2023
0.29.2 10 11/01/2023
0.26.5 11 11/01/2023
0.26.4 9 10/26/2023
0.26.3 8 10/13/2023
0.26.2 10 11/02/2023
0.26.1 7 11/02/2023
0.26.0 13 10/26/2023
0.25.1 11 11/02/2023
0.25.0 9 10/17/2023
0.20.0 11 11/02/2023
0.19.5 9 11/02/2023
0.19.4 9 10/11/2023
0.19.3 7 11/02/2023
0.19.2 7 10/19/2023
0.16.2 8 11/02/2023
0.10.0 7 10/26/2023
0.9.0 13 10/16/2023
0.8.0 8 10/16/2023
0.7.4 11 10/16/2023
0.7.3 12 10/14/2023
0.7.2 9 10/16/2023
0.7.1 9 10/16/2023
0.7.0 10 10/16/2023
0.6.2 12 10/14/2023
0.6.1 8 10/16/2023
0.6.0 10 10/15/2023
0.5.0 9 10/16/2023
0.4.0 10 10/16/2023
0.3.0 8 10/13/2023
0.2.1 12 10/15/2023
0.2.0 10 10/16/2023
0.1.0 7 10/15/2023