MySqlConnector 2.4.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
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,479
Pomelo.EntityFrameworkCore.MySql
Pomelo's MySQL database provider for Entity Framework Core.
1,375
Pomelo.EntityFrameworkCore.MySql
Pomelo's MySQL database provider for Entity Framework Core.
1,175
Pomelo.EntityFrameworkCore.MySql
Pomelo's MySQL database provider for Entity Framework Core.
935
Pomelo.EntityFrameworkCore.MySql
Pomelo's MySQL database provider for Entity Framework Core.
772
Pomelo.EntityFrameworkCore.MySql
Pomelo's MySQL database provider for Entity Framework Core.
51
Pomelo.EntityFrameworkCore.MySql
MySQL provider for Entity Framework Core
43
Pomelo.EntityFrameworkCore.MySql
Pomelo's MySQL database provider for Entity Framework Core.
40
Pomelo.EntityFrameworkCore.MySql
MySQL provider for Entity Framework Core
30
Pomelo.EntityFrameworkCore.MySql
Pomelo's MySQL database provider for Entity Framework Core.
27
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
26
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
25
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
24
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
24
Pomelo.EntityFrameworkCore.MySql
Package Description
24

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

.NET Framework 4.6.2

.NET Standard 2.1

.NET Standard 2.0

.NET 9.0

.NET 8.0

.NET 6.0

.NET Framework 4.8

.NET Framework 4.7.1

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