MySqlConnector 2.6.2
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 Core
For ASP.NET Core, MySqlConnector includes AddMySqlDataSource to integrate with dependency injection and logging.
using MySqlConnector;
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 ofDbConnection)MySqlCommand(implementation ofDbCommand)MySqlDataReader(implementation ofDbDataReader)MySqlBulkCopyMySqlBulkLoaderMySqlConnectionStringBuilderMySqlConnectorFactoryMySqlDataAdapterMySqlExceptionMySqlTransaction(implementation ofDbTransaction)
Related Packages
- Entity Framework Core: Pomelo.EntityFrameworkCore.MySql
Feedback
MySqlConnector is released as open source under the MIT license. Bug reports and contributions are welcome at the GitHub repository.
No packages depend on MySqlConnector.
https://mysqlconnector.net/overview/version-history/
.NET 10.0
- Microsoft.Extensions.Logging.Abstractions (>= 8.0.2)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 8.0.2)
.NET Standard 2.1
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 8.0.2)
- System.Diagnostics.DiagnosticSource (>= 8.0.1)
- Microsoft.Extensions.Logging.Abstractions (>= 8.0.2)
.NET Standard 2.0
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 8.0.2)
- System.Threading.Tasks.Extensions (>= 4.6.3)
- System.Diagnostics.DiagnosticSource (>= 8.0.1)
- Microsoft.Extensions.Logging.Abstractions (>= 8.0.2)
.NET 9.0
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 8.0.2)
- Microsoft.Extensions.Logging.Abstractions (>= 8.0.2)
.NET 8.0
- Microsoft.Extensions.Logging.Abstractions (>= 8.0.2)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 8.0.2)
.NET 6.0
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 8.0.2)
- System.Diagnostics.DiagnosticSource (>= 8.0.1)
- Microsoft.Extensions.Logging.Abstractions (>= 8.0.2)
.NET Framework 4.8
- System.Threading.Tasks.Extensions (>= 4.6.3)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 8.0.2)
- Microsoft.Extensions.Logging.Abstractions (>= 8.0.2)
- System.Diagnostics.DiagnosticSource (>= 8.0.1)
.NET Framework 4.6.2
- System.Diagnostics.DiagnosticSource (>= 8.0.1)
- System.Threading.Tasks.Extensions (>= 4.6.3)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 8.0.2)
- Microsoft.Extensions.Logging.Abstractions (>= 8.0.2)
.NET Framework 4.7.1
- Microsoft.Extensions.Logging.Abstractions (>= 8.0.2)
- System.Threading.Tasks.Extensions (>= 4.6.3)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 8.0.2)
- System.Diagnostics.DiagnosticSource (>= 8.0.1)
| Version | Downloads | Last updated |
|---|---|---|
| 2.6.2 | 6 | 09/16/2026 |
| 2.6.1 | 0 | 06/25/2026 |
| 2.6.0 | 0 | 06/02/2026 |
| 2.5.0 | 0 | 11/12/2025 |
| 2.4.0 | 0 | 11/12/2024 |
| 2.3.7 | 3 | 09/16/2026 |
| 2.3.6 | 0 | 03/20/2024 |
| 2.3.5 | 0 | 01/20/2024 |
| 2.3.4 | 0 | 01/14/2024 |
| 2.3.3 | 0 | 12/19/2023 |
| 2.3.2 | 0 | 12/18/2023 |
| 2.3.1 | 0 | 11/17/2023 |
| 2.3.0 | 0 | 11/14/2023 |
| 2.2.7 | 0 | 07/21/2023 |
| 2.2.6 | 0 | 05/04/2023 |
| 2.2.5 | 0 | 01/01/2023 |
| 2.2.4 | 0 | 12/23/2022 |
| 2.2.3 | 0 | 12/18/2022 |
| 2.2.2 | 0 | 12/06/2022 |
| 2.2.1 | 0 | 11/21/2022 |
| 2.2.0 | 0 | 11/08/2022 |
| 2.1.13 | 0 | 08/26/2022 |
| 2.1.12 | 0 | 08/12/2022 |
| 2.1.11 | 0 | 07/14/2022 |
| 2.1.10 | 0 | 06/04/2022 |
| 2.1.9 | 0 | 05/16/2022 |
| 2.1.8 | 0 | 03/07/2022 |
| 2.1.7 | 0 | 02/20/2022 |
| 2.1.6 | 0 | 02/10/2022 |
| 2.1.5 | 0 | 01/30/2022 |
| 2.1.4 | 0 | 01/25/2022 |
| 2.1.3 | 0 | 01/25/2022 |
| 2.1.2 | 0 | 12/23/2021 |
| 2.1.1 | 0 | 12/21/2021 |
| 2.1.0 | 0 | 11/28/2021 |
| 2.0.0 | 0 | 11/09/2021 |
| 1.3.14 | 0 | 10/20/2021 |
| 1.3.13 | 0 | 10/02/2021 |
| 1.3.12 | 0 | 09/11/2021 |
| 1.3.11 | 0 | 07/02/2021 |
| 1.3.10 | 0 | 06/16/2021 |
| 1.3.9 | 0 | 05/27/2021 |
| 1.3.8 | 0 | 04/30/2021 |
| 1.3.7 | 0 | 04/24/2021 |
| 1.3.6 | 0 | 04/24/2021 |
| 1.3.5 | 0 | 04/23/2021 |
| 1.3.4 | 0 | 04/21/2021 |
| 1.3.3 | 0 | 04/12/2021 |
| 1.3.2 | 0 | 03/22/2021 |
| 1.3.1 | 0 | 03/11/2021 |
| 1.3.0 | 0 | 03/07/2021 |
| 1.2.1 | 0 | 12/12/2020 |
| 1.2.0 | 0 | 11/26/2020 |
| 1.1.0 | 0 | 11/10/2020 |
| 1.0.1 | 0 | 08/13/2020 |
| 1.0.0 | 0 | 07/11/2020 |
| 0.69.10 | 0 | 10/21/2020 |
| 0.69.9 | 0 | 08/20/2020 |
| 0.69.8 | 0 | 07/20/2020 |
| 0.69.7 | 0 | 07/16/2020 |
| 0.69.6 | 0 | 07/07/2020 |
| 0.69.5 | 0 | 07/01/2020 |
| 0.69.4 | 0 | 06/25/2020 |
| 0.69.3 | 0 | 06/16/2020 |
| 0.69.2 | 0 | 06/12/2020 |
| 0.69.1 | 0 | 06/10/2020 |
| 0.69.0 | 0 | 06/08/2020 |
| 0.68.1 | 0 | 06/08/2020 |
| 0.68.0 | 0 | 06/06/2020 |
| 0.67.0 | 0 | 05/30/2020 |
| 0.66.0 | 0 | 05/07/2020 |
| 0.65.0 | 0 | 05/03/2020 |
| 0.64.2 | 0 | 04/28/2020 |
| 0.64.1 | 0 | 04/26/2020 |
| 0.64.0 | 0 | 04/18/2020 |
| 0.63.2 | 0 | 04/09/2020 |
| 0.63.1 | 0 | 04/04/2020 |
| 0.63.0 | 0 | 03/26/2020 |
| 0.62.0 | 0 | 02/29/2020 |
| 0.61.0 | 0 | 11/05/2019 |
| 0.60.4 | 0 | 11/04/2019 |
| 0.60.3 | 0 | 10/28/2019 |
| 0.60.2 | 0 | 10/21/2019 |
| 0.60.1 | 0 | 10/20/2019 |
| 0.60.0 | 0 | 10/19/2019 |
| 0.59.2 | 0 | 10/04/2019 |
| 0.59.1 | 0 | 09/30/2019 |
| 0.59.0 | 0 | 09/25/2019 |
| 0.58.0 | 0 | 09/24/2019 |
| 0.57.0 | 0 | 09/23/2019 |
| 0.56.0 | 0 | 05/26/2019 |
| 0.55.0 | 0 | 05/24/2019 |
| 0.54.0 | 0 | 05/11/2019 |
| 0.53.0 | 0 | 04/19/2019 |
| 0.52.0 | 0 | 04/11/2019 |
| 0.51.1 | 0 | 03/27/2019 |
| 0.51.0 | 0 | 03/27/2019 |
| 0.50.0 | 0 | 03/18/2019 |
| 0.49.3 | 0 | 01/24/2019 |
| 0.49.2 | 0 | 01/16/2019 |
| 0.49.0 | 0 | 01/12/2019 |
| 0.48.2 | 0 | 12/12/2018 |
| 0.48.1 | 0 | 12/10/2018 |
| 0.48.0 | 0 | 12/08/2018 |
| 0.47.1 | 0 | 11/04/2018 |
| 0.47.0 | 0 | 11/03/2018 |
| 0.46.2 | 0 | 10/25/2018 |
| 0.46.1 | 0 | 10/16/2018 |
| 0.46.0 | 0 | 10/12/2018 |
| 0.45.1 | 0 | 09/29/2018 |
| 0.45.0 | 0 | 09/13/2018 |
| 0.44.1 | 0 | 08/24/2018 |
| 0.44.0 | 0 | 08/21/2018 |
| 0.43.0 | 0 | 07/27/2018 |
| 0.42.3 | 0 | 07/06/2018 |
| 0.42.2 | 0 | 06/30/2018 |
| 0.42.1 | 0 | 06/16/2018 |
| 0.42.0 | 0 | 06/09/2018 |
| 0.41.0 | 0 | 06/08/2018 |
| 0.40.4 | 0 | 05/19/2018 |
| 0.40.3 | 0 | 04/26/2018 |
| 0.40.2 | 0 | 04/19/2018 |
| 0.36.0 | 0 | 02/16/2018 |
| 0.35.0 | 0 | 01/21/2018 |
| 0.32.0 | 0 | 11/24/2017 |
| 0.30.0 | 0 | 10/31/2017 |
| 0.29.4 | 0 | 10/31/2017 |
| 0.29.2 | 0 | 10/26/2017 |
| 0.26.5 | 0 | 09/22/2017 |
| 0.26.4 | 0 | 09/13/2017 |
| 0.26.3 | 0 | 09/13/2017 |
| 0.26.2 | 0 | 09/07/2017 |
| 0.26.1 | 0 | 09/03/2017 |
| 0.26.0 | 0 | 08/25/2017 |
| 0.25.1 | 0 | 08/17/2017 |
| 0.25.0 | 0 | 08/13/2017 |
| 0.20.0 | 0 | 06/01/2017 |
| 0.19.5 | 0 | 05/26/2017 |
| 0.19.4 | 0 | 05/13/2017 |
| 0.19.3 | 0 | 05/11/2017 |
| 0.19.2 | 0 | 05/01/2017 |
| 0.16.2 | 0 | 04/02/2017 |
| 0.10.0 | 0 | 12/29/2016 |
| 0.9.0 | 0 | 12/13/2016 |
| 0.8.0 | 0 | 12/07/2016 |
| 0.7.4 | 0 | 12/07/2016 |
| 0.7.3 | 0 | 11/28/2016 |
| 0.7.2 | 0 | 11/23/2016 |
| 0.7.1 | 0 | 11/21/2016 |
| 0.7.0 | 0 | 11/13/2016 |
| 0.6.2 | 0 | 10/28/2016 |
| 0.6.1 | 0 | 10/27/2016 |
| 0.6.0 | 0 | 10/23/2016 |
| 0.5.0 | 0 | 10/20/2016 |
| 0.4.0 | 0 | 10/13/2016 |
| 0.3.0 | 0 | 10/12/2016 |
| 0.2.1 | 0 | 10/10/2016 |
| 0.2.0 | 0 | 10/09/2016 |
| 0.1.0 | 0 | 10/04/2016 |