Connection strings for MySQL
.NET libraries for MySQL
- MySQL Connector/Net - MySqlConnection
- eInfoDesigns.dbProvider - MySqlConnection
- SevenObjects MySqlClient
- dotConnect for MySQL (former MyDirect.NET and Core Labs MySQLDirect.NET) - MySqlConnection
- MySQLDriverCS - MySQLConnection
- .NET Framework Data Provider for OLE DB - OleDbConnection
- .NET Framework Data Provider for ODBC - OdbcConnection
OLE DB providers for MySQL
ODBC drivers for MySQL
MySQL Connector/Net
Usage MySql.Data.MySqlClient.MySqlConnection
Manufacturer MySQL
Standard
Specifying TCP port
The port 3306 is the default MySql port.
The value is ignored if Unix socket is used.
Multiple servers
Use this to connect to a server in a replicated server configuration without concern on which server to use.
Using encryption (old)
This one activates SSL encryption for all data sent between the client and server. The server must have a certificate installed.
This option is available for Connector/NET version 5.0.3 through 6.2.1. From 6.2.1 use the SslMode option instead.
Using encryption (new)
Use SSL if the server supports it, but allow connection in all cases
This option is available from Connector/NET version 6.2.1
Force encryption
Always use SSL. Deny connection if server does not support SSL.
This option is available from Connector/NET version 6.2.1
SSL with a file-based certificate
This option is available from Connector/NET version 6.2.1
SSL with a personal store-based certificate
This option is available from Connector/NET version 6.2.1
SSL with a thumbprint specific personal store-based certificate
This option is available from Connector/NET version 6.2.1
Disallow batches
Allow User Variables
This option is available from Connector/NET version 5.2.2
Invalid DateTime's 1
Returns a MySqlDateTime object for invalid values and a System.DateTime object for valid values.
Invalid DateTime's 2
Returns System.DateTime.MinValue valued System.DateTime object for invalid values and a System.DateTime object for valid values.
Disable transaction participation
The use of auto enlist transactionscope (default behaviour) could cause trouble in medium trust environments.
Skip parameter checks for stored routines
Default behaviour is that parameters for stored routines (stored procedures) are checked against the server
Some permissions and value casting related errors reported fixed when using this connection option.
Skip parameter type and order matching for stored procedures
The default behaviour is to read tables mysql.proc/INFORMATION_SCHEMA.ROUTINES and try to map provided command parameter values to the called procedures parameters and type cast values accordingly.
This can be troublesome if permissions to the (aforementioned) sproc info tables are insufficient.
The driver will not automatically map the parameters so you must manually set parameter types and you must also make sure to add the parameters to the command object in the exact order as appeared in the procedure definition.
This option is available from Connector/NET version 5.0.4
Use Table Caching
Specifying DefaultTableCacheAge is optional, default value is 60 seconds.
This option is available from Connector/NET version 6.4
Count changed rows instead of found rows
This option is available from Connector/NET version 5.2.6
Compress network communication between client and server
Log inefficient database operations
Enable performance counters
Connection Pooling
From version 6.2 idle connections are removed from the pool, freeing resources on the client (sockets) and the server (sockets and threads). Do not manually keep (global) connections and open close. Keep connection object creation and disposal as tight as possible, this might be counterintuitive but pooling mechanisms will take care of caching well and your code will be cleaner.
This is the default behaviour.
Connection Pool size
Default values are 0 and 100.
Disable connection pooling
Connection state reset when obtained from pool
Makes an additional round trip to the server when obtaining a connection from the pool and connection state will be reset.
Recycle connections in pool
This is useful in load balancing scenarios when available servers change you don't want 100 constant connections in the pool pointing to only one server.
Specified in seconds, the amount of time after connection object creation the connection will be destroyed. Destruction will only happen when connections are returned to pool.
Do not update server settings on connections in pool
A connection might be long lived in the pool, however the connections server settings are updated (SHOW VARIABLES command) each time returned to the pool. This makes the client use of the connection object up to date with the correct server settings. However this causes a round trip and to optimize pooling performance this behaviour can be turned off.
This option is available from Connector/NET version 6.3
Use Windows authentication
This option is available from Connector/NET version 6.4.4
The Windows Native Authentication Plugin must be installed for this to work.
Keep TCP Sockets alive
Number of seconds between each keep-alive package send.
Use BINARY(16) GUIDs
This option is available from Connector/NET version 6.1.1
Disable Stored procedure cache
The default is 25, meaning that stored procedure meta data (such as input/output data types etc) for the latest 25 called procedures will be cached in client memory.
This option is available from Connector/NET version 5.0.2
Allow square brackets around symbols (instead of backticks)
This enables Visual Studio wizards that bracket symbols with [] to work with Connector/Net. This option incurs a performance hit, so should only be used if necessary.
This option is available from Connector/NET version 6.3.1
Specifying default command timeout
Use this one to specify a default command timeout for the connection. Please note that the property in the connection string does not supercede the individual command timeout property on an individual command object.
This option is available from Connector/NET version 5.1.4.
Specifying connection attempt timeout
Use this one to specify the length in seconds to wait for a server connection before terminating the attempt and receive an error.
Inactivating prepared statements
Use this one to instruct the provider to ignore any command prepare statements and prevent corruption issues with server side prepared statements.
The option was added in Connector/NET version 5.0.3 and Connector/NET version 1.0.9.
Specifying network protocol
Use this one to specify which network protocol to use for the connection.
"socket" is the default value used if the key isn't specified. Value "tcp" is an equivalent for "socket".
Use "pipe" to use a named pipes connection, "unix" for a Unix socket connection and "memory" to use MySQL shared memory.
Shared memory protocol
It's possible to explicit set the shared memory object name used for communication.
Named pipes protocol
It's possible to explicit set the pipe name used for communication, if not set, 'mysql' is the default value.
Named pipes alternative
It is the port value of -1 that tells the driver to use named pipes network protocol. This is available on Windows only. The value is ignored if Unix socket is used.
Unix socket connection
It's possible to explicit set the shared memory object name used for communication.
Specifying character set
Use this one to specify which character set to use to encode queries sent to the server.
Note! Use lower case value utf8 and not upper case UTF8 as this will fail.
Note that resultsets still are returned in the character set of the data returned.
eInfoDesigns.dbProvider
Usage eInfoDesigns.dbProvider.MySqlClient.MySqlConnection
Manufacturer eInfoDesigns
Standard
SevenObjects MySqlClient
Usage
Manufacturer SevenObjects
dotConnect for MySQL (former MyDirect.NET and Core Labs MySQLDirect.NET)
Usage Devart.Data.MySql.MySqlConnection
Manufacturer Devart
Standard
MySQLDriverCS
Usage MySQLDriverCS.MySQLConnection
Manufacturer MySQLDriverCS project team
Standard
MySQL OLEDB
Usage Provider=MySQLProv
Manufacturer MySQL
.NET Framework Data Provider for OLE DB
Usage System.Data.OleDb.OleDbConnection
Manufacturer Microsoft
Use an OLE DB provider from .NET
See the respective OLEDB provider's connection strings options. The .net OleDbConnection will just pass on the connection string to the specified OLEDB provider. Read more here.
MyODBC 2.50
Usage Driver={mySQL}
Manufacturer MySQL
Local database
Remote database
Specifying TCP/IP port
The driver defaults to port value 3306, if not specified in the connection string, as 3306 is the default port for MySQL.
MySQL Connector/ODBC 3.51
Usage Driver={MySQL ODBC 3.51 Driver}
Manufacturer MySQL
Local database
Remote database
Specifying TCP/IP port
The driver defaults to port value 3306, if not specified in the connection string, as 3306 is the default port for MySQL.
Specifying character set
Note that the charset option works from version 3.51.17 of the driver.
Specifying socket
This one specifies the Unix socket file or Windows named pipe to connect to. Used only for local client connections.
On Windows, the socket variable is the name of the named pipe that is used for local client connections. The default value is MySQL.
On Unix platforms, the socket variable is the name of the socket file that is used for local client connections. The default is /tmp/mysql.sock.
Using SSL
SSLCA specifies the path to a file with a list of trust SSL CAs
SSLCERT specifies the name of the SSL certificate file to use for establishing a secure connection.
SSLKEY specifies the name of the SSL key file to use for establishing a secure connection.
MySQL Connector/ODBC 5.1
Usage Driver={MySQL ODBC 5.1 Driver}
Manufacturer MySQL
Local database
On 64 bit machine
It seems we need to point on MSDASQL for the (32 bit) ODBC driver to work on 64 bit machines.
64 bit version of the driver
Note the "w" in the driver name.
Remote database
Specifying TCP/IP port
The driver defaults to port value 3306, if not specified in the connection string, as 3306 is the default port for MySQL.
Specifying character set
Specifying socket
This one specifies the Unix socket file or Windows named pipe to connect to. Used only for local client connections.
On Windows, the socket variable is the name of the named pipe that is used for local client connections. The default value is MySQL.
On Unix platforms, the socket variable is the name of the socket file that is used for local client connections. The default is /tmp/mysql.sock.
Using SSL
SSLCA specifies the path to a file with a list of trust SSL CAs
SSLCERT specifies the name of the SSL certificate file to use for establishing a secure connection.
SSLKEY specifies the name of the SSL key file to use for establishing a secure connection.
.NET Framework Data Provider for ODBC
Usage System.Data.Odbc.OdbcConnection
Manufacturer Microsoft
Use an ODBC driver from .NET
See the respective ODBC driver's connection strings options. The .net OdbcConnection will just pass on the connection string to the specified ODBC driver. Read more here.