This chapter describes both the general MySQL Connector/NET 6.10 connection-string options that apply to all server configurations and the options related to systems using a connection pool (see Connection Pooling Options). Connection options have a default value that you can override by defining the new value in the connection string. Connector/NET option names and synonyms are not case-sensitive.
For instructions about how to use connection strings with Connector/NET, see Section 4.4.1, “Creating a Connector/NET Connection String”.
The Connector/NET 6.10 options that follow are for general use with connection strings and apply to all MySQL server configurations:
-
AllowBatch
,Allow Batch
Default:
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. Statements sent to earlier versions of MySQL should be separated by the semicolon character (;).-
AllowLoadLocalInfile
,Allow Load Local Infile
Default:
false
Disables (by default) or enables the server functionality to load the data local infile.
-
AllowUserVariables
,Allow User Variables
Default:
false
Setting this to
true
indicates that the provider expects user variables in the SQL. This option was introduced with the 5.2.2 connector.-
AllowZeroDateTime
,Allow Zero Datetime
Default:
false
If set to
True
,MySqlDataReader.GetValue()
returns aMySqlDateTime
object for date or datetime columns that have disallowed values, such as zero datetime values, and aSystem.DateTime
object for valid values. If set toFalse
(the default setting) it causes aSystem.DateTime
object to be returned for all valid values and an exception to be thrown for disallowed values, such as zero datetime values.-
AutoEnlist
,Auto Enlist
Default:
true
If
AutoEnlist
is set totrue
, which is the default, a connection opened usingTransactionScope
participates in this scope, it commits when the scope commits and rolls back ifTransactionScope
does not commit. However, this feature is considered security sensitive and therefore cannot be used in a medium trust environment.As of 6.10.6, this option is supported in .NET Core 2.0 implementations.
-
BlobAsUTF8ExcludePattern
Default:
null
A POSIX-style regular expression that matches the names of BLOB columns that do not contain UTF-8 character data. See Section 4.5.14, “Character Set Considerations for Connector/NET” for usage details.
-
BlobAsUTF8IncludePattern
Default:
null
A POSIX-style regular expression that matches the names of BLOB columns containing UTF-8 character data. See Section 4.5.14, “Character Set Considerations for Connector/NET” for usage details.
-
CertificateFile
,Certificate File
Default:
null
This option specifies the path to a certificate file in PKCS #12 format (
.pfx
). For an example of usage, see Section 4.6.10, “Tutorial: Configuring SSL with Connector/NET”. This option was introduced with the 6.2.1 connector.-
CertificatePassword
,Certificate Password
Default:
null
Specifies a password that is used in conjunction with a certificate specified using the option
CertificateFile
. For an example of usage, see Section 4.6.10, “Tutorial: Configuring SSL with Connector/NET”. This option was introduced with the 6.2.1 connector.-
CertificateStoreLocation
,Certificate Store Location
Default:
null
Enables 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 Section 4.6.10, “Tutorial: Configuring SSL with Connector/NET”. This option was introduced with the 6.2.1 connector.
-
CertificateThumbprint
,Certificate Thumbprint
Default:
null
Specifies a certificate thumbprint to ensure correct identification of a certificate contained within a personal store. For an example of usage, see Section 4.6.10, “Tutorial: Configuring SSL with Connector/NET”. This option was introduced with the 6.2.1 connector.
-
CharacterSet
,CharSet
,Character Set
Specifies the character set that should be used to encode all queries sent to the server. Results are still returned in the character set of the result data.
-
CheckParameters
,Check Parameters
Default:
true
Indicates if stored routine parameters should be checked against the server.
-
CommandInterceptors
,Command Interceptors
The list of interceptors that can intercept SQL command operations.
-
ConnectionProtocol
,Protocol
,Connection Protocol
Default:
socket
ortcp
Specifies the type of connection to make to the server. Values can be:
socket
ortcp
for a socket connection.pipe
for a named pipe connection.unix
for a UNIX socket connection.memory
to use MySQL shared memory.
-
ConnectionTimeout
,Connect Timeout
,Connection Timeout
Default: 15
The length of time (in seconds) to wait for a connection to the server before terminating the attempt and generating an error.
-
ConvertZeroDateTime
,Convert Zero Datetime
Default:
false
Use
true
to haveMySqlDataReader.GetValue()
andMySqlDataReader.GetDateTime()
returnDateTime.MinValue
for date or datetime columns that have disallowed values.-
Database
,Initial Catalog
Default: mysql
The case-sensitive name of the database to use initially.
-
DefaultCommandTimeout
,Default Command Timeout
Default: 30
Sets the default value of the command timeout to be used. This does not supersede the individual command timeout property on an individual command object. If you set the command timeout property, that will be used. This option was introduced with the 5.1.4 connector.
-
DefaultTableCacheAge
,Default Table Cache Age
Default: 60
Specifies how long a
TableDirect
result should be cached, in seconds. For usage information about table caching, see Section 4.5.4, “Using Connector/NET with Table Caching”. This option was introduced with the 6.4 connector.-
ExceptionInterceptors
,Exception Interceptors
The list of interceptors that can triage thrown
MySqlException
exceptions.-
FunctionsReturnString
,Functions Return String
Default:
false
Causes the connector to return
binary
orvarbinary
values as strings, if they do not have a table name in the metadata.-
IgnorePrepare
,Ignore Prepare
Default:
true
When
true
, instructs the provider to ignore any calls toMySqlCommand.Prepare()
. This option is provided to prevent issues with corruption of the statements when used with server-side prepared statements. If you use server-side prepare statements, set this option to false. This option was introduced with the 5.0.3 and 1.0.9 connectors.-
IncludeSecurityAsserts
,Include Security Asserts
Default:
false
Must be set to
true
when using theMySQLClientPermissions
class in a partial trust environment, with the library installed in the GAC of the hosting environment. This requirement is new for partial-trust applications in Connector/NET 6.6.4 and higher. See Section 4.5.17, “Working with Partial Trust / Medium Trust” for details.As of 6.10.6, this option is supported in .NET Core 2.0 implementations.
-
IntegratedSecurity
,Integrated Security
Default: no
Use Windows authentication when connecting to server. By default, it is turned off. To enable, specify a value of
yes
. (You can also use the valuesspi
as an alternative toyes
.) For details, see Section 4.5.3.1, “Using the Windows Native Authentication Plugin”. This setting only applies to the Windows platform and was introduced with the 6.4.4 connector.Currently not supported for .NET Core implementations.
-
InteractiveSession
,Interactive
,Interactive Session
Default:
false
If set to
true
, the client is interactive. An interactive client is one where the server variableCLIENT_INTERACTIVE
is set. If an interactive client is set, thewait_timeout
variable is set to the value ofinteractive_timeout
. The client will then time out after this period of inactivity. For more details, see Server System Variables in the MySQL Reference Manual.As of 6.10.6, this option is supported in .NET Core 2.0 implementations.
-
Keepalive
,Keep Alive
Default: 0
For TCP connections, idle connection time measured in seconds, before the first keepalive packet is sent. A value of 0 indicates that
keepalive
is not used. Before Connector/NET 6.6.7/6.7.5/6.8.4, this value was measured in milliseconds.-
Logging
Default:
false
When true, various pieces of information is output to any configured TraceListeners. See Section 4.5.12, “Using the Connector/NET Trace Source Object” for further details.
As of 6.10.6, this option is supported in .NET Core 2.0 implementations.
-
OldGuids
,Old Guids
Default:
false
This option was introduced in Connector/NET 6.1.1. The back-end representation of a GUID type was changed from
BINARY(16)
toCHAR(36)
. This was done to allow developers to use the server functionUUID()
to populate a GUID table -UUID()
generates a 36-character string. Developers of older applications can add'Old Guids=true'
to the connection string to use a GUID of data typeBINARY(16)
.-
Password
,pwd
The password for the MySQL account being used.
-
PersistSecurityInfo
,Persist Security Info
Default:
false
When set to
false
orno
(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 aretrue
,false
,yes
, andno
.-
PipeName
,Pipe Name
,Pipe
Default: mysql
When set to the name of a named pipe, the
MySqlConnection
attempts to connect to MySQL on that named pipe. This setting only applies to the Windows platform.Currently not supported for .NET Core implementations.
-
Port
Default: 3306
The port MySQL is using to listen for connections. This value is ignored if Unix socket is used.
-
ProcedureCacheSize
,Procedure Cache Size
,Procedure Cache
,ProcedureCache
Default: 25
Sets the size of the stored procedure cache. By default, Connector/NET stores the metadata (input/output data types) about the last 25 stored procedures used. To disable the stored procedure cache, set the value to zero (0). This option was introduced with the 5.0.2 and 1.0.9 connectors.
-
Replication
Default:
false
Indicates if this connection is to use replicated servers.
As of 6.10.6, this option is supported in .NET Core 2.0 implementations.
-
RespectBinaryFlags
,Respect Binary Flags
Default:
true
Setting this option to
false
means that Connector/NET ignores a column's binary flags as set by the server. This option was introduced with the 5.1.3 connector.-
Server
,Host
,Data Source
,DataSource
,Address
,Addr
,Network Address
Default:
localhost
The name or network address of the instance of MySQL to which to connect. Multiple hosts can be specified separated by commas. 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 take care when using this option. In Unix environment with Mono, this can be a fully qualified path to a MySQL socket file. With this configuration, the Unix socket is used instead of the 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.
-
SharedMemoryName
,Shared Memory Name
Default: MYSQL
The name of the shared memory object to use for communication if the transport protocol is set to
memory
. This setting only applies to the Windows platform.Currently not supported for .NET Core implementations.
-
SqlServerMode
,Sql Server Mode
Default:
false
Allow SQL Server syntax. When set to
true
, enables Connector/NET to support 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 was introduced with the 6.3.1 connector.-
SslMode
,Ssl Mode
,Ssl-Mode
Default:
Preferred
This option was introduced in Connector/NET 6.2.1 and 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.
-
TableCaching
,Table Cache
,tablecache
Default:
false
Enables or disables caching of
TableDirect
commands. A value oftrue
enables the cache whilefalse
disables it. For usage information about table caching, see Section 4.5.4, “Using Connector/NET with Table Caching”. This option was introduced with the 6.4 connector.-
TreatBlobsAsUTF8
,Treat BLOBs as UTF8
Default:
false
Setting this value to
true
causesBLOB
columns to have a character set ofutf8
with the default collation for that character set.-
TreatTinyAsBoolean
,Treat Tiny As Boolean
Default:
true
Setting this value to
false
causesTINYINT(1)
to be treated as anINT
. See Numeric Data Type Syntax for a further explanation of theTINYINT
andBOOL
data types.-
UseAffectedRows
,Use Affected Rows
Default:
false
When
true
, the connection reports changed rows instead of found rows. This option was introduced with the 5.2.6 connector.-
UseCompression
,Compress
,Use Compression
Default:
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, 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.
-
UseDefaultCommandTimeoutForEF
,Use Default Command Timeout For EF
Default:
false
Enforces the command timeout of
EFMySqlCommand
, which is set to the value provided by theDefaultCommandTimeout
property.-
UseOldSyntax
,Old Syntax
,OldSyntax
,Use Old Syntax
Default:
false
This option was deprecated in Connector/NET 5.2.2 and removed in Connector/NET 6.10.2. All code should now be written using the '@' symbol as the parameter marker.
-
UsePerformanceMonitor
,Use Performance Monitor
,UserPerfmon
,Perfmon
Default:
false
Indicates that performance counters should be updated during execution.
Currently not supported for .NET Core implementations.
-
UseProcedureBodies
,Use Procedure Bodies
,Procedure Bodies
Default:
true
When set to
true
, the default value, Connector/NET expects the body of the procedure to be viewable. This enables it to determine the parameter types and order. Set the option tofalse
when the user connecting to the database does not have theSELECT
privileges for themysql.proc
(stored procedures) table or cannot viewINFORMATION_SCHEMA.ROUTINES
, and then explicitly set the types of all the parameters before the call and add the parameters to the command in the same order as they appear in the procedure definition.This option was deprecated in Connector/NET 6.3.7 and removed in Connector/NET 6.10.4; use the
Check Parameters
option instead.-
UserID
,User Id
,Username
,Uid
,User name
,User
The MySQL login account being used.
-
UseUsageAdvisor
,Use Usage Advisor
,Usage Advisor
Default:
false
Logs inefficient database operations.
As of 6.10.6, this option is supported in .NET Core 2.0 implementations.
The following options are related to connection pooling within connection strings. For more information about connection pooling, see Opening a Connection to a Single Server.
-
CacheServerProperties
,Cache Server Properties
Default:
false
Specifies whether server variable settings are updated by a
SHOW VARIABLES
command each time a pooled connection is returned. Enabling this setting speeds up connections in a connection pool environment. Your application is not informed of any changes to configuration variables made by other connections. This option was introduced with the 6.3 connector.-
ConnectionLifeTime
,Connection Lifetime
Default: 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.-
ConnectionReset
,Connection Reset
Default:
false
If
true
, the connection state is reset when it is retrieved from the pool. The default value of false avoids making an additional server round trip when obtaining a connection, but the connection state is not reset.-
MaximumPoolsize
,Maximum Pool Size
,Max Pool Size
,MaxPoolSize
Default: 100
The maximum number of connections allowed in the pool. This option applies to Connector/NET 6.7 and higher.
-
MinimumPoolSize
,Minimum Pool Size
,Min Pool Size
,MinPoolSize
Default: 0
The minimum number of connections allowed in the pool. This option applies to Connector/NET 6.7 and higher.
-
Pooling
Default:
true
When
true
, theMySqlConnection
object is drawn from the appropriate pool, or if necessary, is created and added to the appropriate pool. Recognized values aretrue
,false
,yes
, andno
.