Connection Options

MySQL Connector/Net

Connector/NET Connection String Options Reference

Name

Default

Description

Allow Batch

true

When true, multiple SQL statements can be sent with one command execution. -Note- Starting with MySQL 4.1.1, batch statements should be separated by the server-defined separator character. Commands sent to earlier versions of MySQL should be separated with ';'.

Allow User Variables

false

Setting this to true indicates that the provider expects user variables in the SQL. This option was added in Connector/NET version 5.2.2.

Allow Zero Datetime

false

True to have MySqlDataReader.GetValue() return a MySqlDateTime for date or datetime columns that have illegal values. False will cause a System.DateTime object to be returned for legal values and an exception will be thrown for illegal values.

AutoEnlist

true

BlobAsUTF8ExcludePattern

null

BlobAsUTF8IncludePattern

null

CertificateFile

null

This option specifies the path to a certificate file in PFX format. For an example of usage see

Tutorial: Using SSL with. Was introduced with 6.2.1.

CertificatePassword

null

This option allows you to specify a password which is used in conjunction with a certificate specified using the option CertificateFile. For an example of usage see Tutorial: Using SSL with. Was introduced with 6.2.1.

Certificate Store Location

null

This option allows you to access a certificate held in a personal store, rather than use a certificate file and password combination. For an example of usage see Tutorial: Using SSL with. Was introduced with 6.2.1.

Certificate Thumbprint

null

This option allows you to specify a certificate thumbprint to ensure correct identifcation of a certificate contained within a personal store. For an example of usage see Tutorial: Using SSL with. Was introduced with 6.2.1.

CharSet, Character Set

Specifies the character set that should be used to encode all queries sent to the server. Resultsets are still returned in the character set of the data returned.

Connect Timeout, Connection Timeout

15

The length of time (in seconds) to wait for a connection to the server before terminating the attempt and generating an error.

Connection Reset

false

Convert Zero Datetime

false

True to have MySqlDataReader.GetValue() and MySqlDataReader.GetDateTime() return DateTime.MinValue for date or datetime columns that have illegal values.

Default Command Timeout

30

Sets the default value of the command timeout to be used. This does not supercede the individual command timeout property on an individual command object. If you set the command timeout property, that will be used. This option was added in Connector/NET 5.1.4

Encrypt, UseSSL

false

For Connector/NET 5.0.3 and later, when true, SSL encryption is used for all data sent between the client and server if the server has a certificate installed. Recognized values are true, false, yes, and no. In versions before 5.0.3, this option had no effect. From version 6.2.1 this option is deprecated and is replaced by SSL Mode. However, the option is still supported if used. If this option is set to true it is equivalent to SSL Mode = Preferred.

FunctionsReturnString

false

This will cause the connector to return binary/varbinary values as strings, if they do not have a tablename in the metadata.

Host, Server, Data Source, DataSource, Address, Addr, Network Address

localhost

The name or network address of the instance of MySQL to which to connect. Multiple hosts can be specified separated by &. This can be useful where multiple MySQL servers are configured for replication and you are not concerned about the precise server you are connecting to. No attempt is made by the provider to synchronize writes to the database so care should be taken when using this option. In Unix environment with Mono, this can be a fully qualified path to MySQL socket file name. With this configuration, the Unix socket will be used instead of TCP/IP socket. Currently only a single socket name can be given so accessing MySQL in a replicated environment using Unix sockets is not currently supported.

Ignore Prepare

true

When true, instructs the provider to ignore any calls to MySqlCommand.Prepare(). This option is provided to prevent issues with corruption of the statements when use with server side prepared statements. If you want to use server-side prepare statements, set this option to false. This option was added in Connector/NET 5.0.3 and Connector/NET 1.0.9.

Initial Catalog, Database

mysql

The name of the database to use intially

InteractiveSession

false

Logging

false

When true, various pieces of information is output to any configured TraceListeners.

Old Guids

false

This option was introduced in Connector/NET 6.1.1. The backend representation of a GUID type was changed from BINARY(16) to CHAR(36). This was done to allow developers to use the server function UUID() to populate a GUID table - UUID() generates a 36-character string. Developers of older applications can add 'Old Guids=true' to the connection string in order to use a GUID of data type BINARY(16).

Old Syntax, OldSyntax

false

This option was deprecated in Connector/NET 5.2.2. All code should now be written using the '@' symbol as the parameter marker.

Password, pwd

The password for the MySQL account being used.

Persist Security Info

false

When set to false or no (strongly recommended), security-sensitive information, such as the password, is not returned as part of the connection if the connection is open or has ever been in an open state. Resetting the connection string resets all connection string values including the password. Recognized values are true, false, yes, and no.

Pipe Name, Pipe

mysql

When set to the name of a named pipe, the MySqlConnection will attempt to connect to MySQL on that named pipe.This settings only applies to the Windows platform.

Port

3306

The port MySQL is using to listen for connections. This value is ignored if Unix socket is used.

Procedure Cache Size

25

Sets the size of the stored procedure cache. By default, Connector/NET will store the metadata (input/output datatypes) about the last 25 stored procedures used. To disable the stored procedure cache, set the value to zero (0). This option was added in Connector/NET 5.0.2 and Connector/NET 1.0.9.

Protocol

socket

Specifies the type of connection to make to the server. Values can be: socket or tcp for a socket connection, pipe for a named pipe connection, unix for a Unix socket connection, memory to use MySQL shared memory.

Respect Binary Flags

true

Setting this option to false means that Connector/NET will ignore a column's binary flags as set by the server. This option was added in Connector/NET version 5.1.3.

Shared Memory Name

MYSQL

The name of the shared memory object to use for communication if the connection protocol is set to memory.

SSL Mode

None

This option has the following values:

  • None - do not use SSL.

  • Preferred - use SSL if the server supports it, but allow connection in all cases.

  • Required - Always use SSL. Deny connection if server does not support SSL.

  • VerifyCA - Always use SSL. Validate the CA but tolerate name mismatch.

  • VerifyFull - Always use SSL. Fail if the host name is not correct.

This option was introduced in 6.1.1.

TreatBlobsAsUTF8

false

Treat Tiny As Boolean

true

Setting this value to false indicates that TINYINT(1) will be treated as an INT. See also [numeric-type-overview] for a further explanation of the TINYINT and BOOL data types.

Use Affected Rows

false

When true the connection will report changed rows instead of found rows. This option was added in Connector/NET version 5.2.6.

Use Procedure Bodies

true

Setting this option to false indicates that the user connecting to the database does not have the SELECT privileges for the mysql.proc (stored procedures) table. When to set to false, Connector/NET will not rely on this information being available when the procedure is called. Because Connector/NET will be unable to determine this information, you should explicitly set the types of the all the parameters before the call and the parameters should be added to the command in the exact same order as they appear in the procedure definition. This option was added in Connector/NET 5.0.4 and Connector/NET 1.0.10.

User Id, Username, Uid, User name

The MySQL login account being used.

Use Compression

false

Setting this option to true enables compression of packets exchanged between the client and the server. This exchange is defined by the MySQL client-server protocol.

Compression is used if both client and server support ZLIB compression, and the client has requested compression using this option.

A compressed packet header is: packet length (3 bytes), packet number (1 byte), and Uncompressed Packet Length (3 bytes). The Uncompressed Packet Length is the number of bytes in the original, uncompressed packet. If this is zero then the data in this packet has not been compressed. When the compression protocol is in use, either the client or the server may compress packets. However, compression will not occur if the compressed length is greater than the original length. Thus, some packets will contain compressed data while other packets will not.

Use Usage Advisor

false

Use Performance Monitor

false

The following table lists the valid names for connection pooling values within the ConnectionString. For more information about connection pooling, see Connection Pooling for the MySQL Data Provider.

Name

Default

Description

Cache Server Configuration, CacheServerConfiguration, CacheServerConfig

false

Specifies whether server variables should be updated when a pooled connection is returned. Turning this on will yield faster opens but will also not catch any server changes made by other connections.

Connection Lifetime

0

When a connection is returned to the pool, its creation time is compared with the current time, and the connection is destroyed if that time span (in seconds) exceeds the value specified by Connection Lifetime. This is useful in clustered configurations to force load balancing between a running server and a server just brought online. A value of zero (0) causes pooled connections to have the maximum connection timeout.

Max Pool Size

100

The maximum number of connections allowed in the pool.

Min Pool Size

0

The minimum number of connections allowed in the pool.

Pooling

true

When true, the MySqlConnection object is drawn from the appropriate pool, or if necessary, is created and added to the appropriate pool. Recognized values are true, false, yes, and no.

Reset Pooled Connections, ResetConnections, ResetPooledConnections

true

Specifies whether a ping and a reset should be sent to the server before a pooled connection is returned. Not resetting will yield faster connection opens but also will not clear out session items such as temp tables.