This chapter describes the full set of MySQL Connector/NET 8.0 connection options. The protocol you use to make a connection to the server (classic MySQL protocol or X Protocol) determines which options you should use. Connection options have a default value that you can override by defining the new value in the connection string (classic MySQL protocol and X Protocol) or in the URI-like connection string (X Protocol). Connector/NET option names and synonyms are not case sensitive.
For instructions about how to use connection strings, see Section 4.4.1, “Creating a Connector/NET Connection String”. For alternative connection styles, see Connecting to the Server Using URI-Like Strings or Key-Value Pairs.
The following sections list the connection options that apply to both protocols, classic MySQL protocol only, and X Protocol only:
The following Connector/NET connection options can be used with either
protocol. Connector/NET 8.0 exposes the options in this section as
properties in both the
MySql.Data.MySqlClient.MySqlConnectionStringBuilder
and
MySqlX.XDevAPI.MySqlXConnectionStringBuilder
classes.
-
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.7.2, “Using PFX Certificates in Connector/NET”.-
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.7.2, “Using PFX Certificates in Connector/NET”.-
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.7.2, “Using PFX Certificates in Connector/NET”.
-
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.7.2, “Using PFX Certificates in Connector/NET”.
-
CharacterSet
,Character Set
,CharSet
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.
-
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 using TCP/IP.pipe
for a named pipe connection (not supported with X Protocol).unix
for a UNIX socket connection.memory
to use MySQL shared memory (not supported with X Protocol).
-
Database
,Initial Catalog
Default:
mysql
The case-sensitive name of the database to use initially.
-
dns-srv
,dnssrv
Default:
false
Enables the connection to resolve service (SRV) addresses in a DNS SRV record, which defines the location (host name and port number) of servers for the specified services when it is used with the default transport protocol (
tcp
). A single DNS domain can map to multiple targets (servers) using SRV address records. Each SRV record includes the host name, port, priority, and weight. DNS SRV support was introduced in Connector/NET 8.0.19 to remove the need for clients to identify each possible host in the connection string, with or without connection pooling.Specifying multiple host names, a port number, or a Unix socket, named pipe, or shared memory connection (see the
ConnectionProtocol
option) in the connection string is not permitted when DNS SRV is enabled.Using classic MySQL protocol. The
dns-srv
option applies to connection strings; theDnsSrv
property is declared in theMySqlConnectionStringBuilder
class.// Connection string example var conn = new MySqlConnection("server=_mysql._tcp.example.abc.com.; dns-srv=true; user id=user; password=****; database=test"); // MySqlConnectionStringBuilder class example var sb = new MySqlConnectionStringBuilder(); { Server = "_mysql._tcp.example.abc.com.", UserID = "user", Password = "****", DnsSrv = true, Database = "test" }; var conn = new MySqlConnection(sb.ConnectionString);
Using X Protocol. The
dns-srv
option applies to connection strings and anonymous objects. TheDnsSrv
property is declared in theMySqlXConnectionStringBuilder
class. An error is raised if bothdns-srv=false
and the URI scheme ofmysqlx+srv://
are combined to create a conflicting connection configuration. For details about using themysqlx+srv://
scheme element in URI-like connection strings, see Connections Using DNS SRV Records.// Connection string example var session = MySQLX.GetSession("server=_mysqlx._tcp.example.abc.com.; dns-srv=true; user id=user; password=****; database=test"); // Anonymous object example var connstring = new { server = "_mysqlx._tcp.example.abc.com.", user = "user", password = "****", dnssrv = true }; var session = MySQLX.GetSession(connString); // MySqlXConnectionStringBuilder class example var sb = new MySqlXConnectionStringBuilder(); { Server = "_mysqlx._tcp.example.abc.com.", UserID = "user", Password = "****", DnsSrv = true, Database = "test" }; var session = MySQLX.GetSession(sb.ConnectionString);
-
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.-
Password
,Password1
,pwd
,pwd1
Default: an empty string
The password for the MySQL account being used for one-factor/single-factor authentication (1FA/SFA), which uses only one authentication method such as a password.
Starting with Connector/NET 8.0.28, this option also provides the first secret password for an account that has multiple authentication factors. The server can require one (1FA), two (2FA), or three (3FA) passwords to authenticate the MySQL account. For example, if an account with 2FA is created as follows:
CREATE USER 'abe'@'localhost' IDENTIFIED WITH caching_sha2_password BY 'sha2_password' AND IDENTIFIED WITH authentication_ldap_sasl AS 'uid=u1_ldap,ou=People,dc=example,dc=com';
Then your application can specify a connection string with this option (
password
or its synonyms) and a value,sha2_password
in this case, to satisfy the first authentication factor.var connString = "server=localhost; user=abe; password=sha2_password; password2=ldap_password; port=3306";
Alternatively, for a connection made using the
MySqlConnectionStringBuilder
object:MySqlConnectionStringBuilder settings = new MySqlConnectionStringBuilder() { Server = "localhost", UserID = "abe", Pwd1 = "sha2_password", Pwd2 = "ldap_password", Port = 3306 };
If the server does not require a secret password be used with an authentication method, then the value specified for the
password
,password2
, orpassword3
option is ignored.-
Password2
,pwd2
Default: an empty string
The second secret password for an account that has multiple authentication factors (see the
Password
connection option).-
Password3
,pwd3
Default: an empty string
The third secret password for an account that has multiple authentication factors (see the
Password
connection option).-
Port
Default:
3306
The port MySQL is using to listen for connections. This value is ignored if Unix socket is used.
-
Server
,Host
,Data Source
,DataSource
Default:
localhost
The name or network address of one or more host computers. Multiple hosts are separated by commas and a priority (0 to 100), if provided, determines the host selection order. As of Connector/NET 8.0.19, host selection is random when priorities are omitted or are the same for each host.
// Selects the host with the highest priority (100) first server=(address=192.10.1.52:3305,priority=60),(address=localhost:3306,priority=100);
No attempt is made by the provider to synchronize writes to the database, so take care when using this option. In UNIX environments 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.
-
SslCa
,Ssl-Ca
Default:
null
Based on the type of certificates being used, this option either specifies the path to a certificate file in PKCS #12 format (
.pfx
) or the path to a file in PEM format (.pem
) that contains a list of trusted SSL certificate authorities (CA).With PFX certificates in use, this option engages when the
SslMode
connection option is set to a value ofRequired
,VerifyCA
, orVerifyFull
; otherwise, it is ignored.With PEM certificates in use, this option engages when the
SslMode
connection option is set to a value ofVerifyCA
orVerifyFull
; otherwise, it is ignored.For examples of usage, see Section 4.6.7.1, “Using PEM Certificates in Connector/NET”.
-
SslCert
,Ssl-Cert
Default:
null
The name of the SSL certificate file in PEM format to use for establishing an encrypted connection. This option engages only when
VerifyFull
is set for theSslMode
connection option and theSslCa
connection option uses a PEM certificate; otherwise, it is ignored. For an example of usage, see Section 4.6.7.1, “Using PEM Certificates in Connector/NET”.-
SslKey
,Ssl-Key
Default:
null
The name of the SSL key file in PEM format to use for establishing an encrypted connection. This option engages only when
VerifyFull
is set for theSslMode
connection option and theSslCa
connection option uses a PEM certificate; otherwise, it is ignored. For an example of usage, see Section 4.6.7.1, “Using PEM Certificates in Connector/NET”.-
SslMode
,Ssl Mode
,Ssl-Mode
Default: Depends on the version of Connector/NET and the protocol in use. Named-pipe and shared-memory connections are not supported with X Protocol.
Required
for 8.0.8 to 8.0.12 (both protocols); 8.0.13 and later (X Protocol only).Preferred
for 8.0.13 and later (classic MySQL protocol only).
This option has the following values:
Disabled
– Do not use SSL. Non-SSL enabled servers require this option be set toDisabled
explicitly for Connector/NET 8.0.29 or later.None
– Do not use SSL. Non-SSL enabled servers require this option be set toNone
explicitly for Connector/NET 8.0.8 or later.NoteThis value is deprecated starting with Connector/NET 8.0.29. Use
Disabled
instead.Preferred
– Use SSL if the server supports it, but allow connection in all cases. This option was removed in Connector/NET 8.0.8 and reimplemented in 8.0.13 for classic MySQL protocol only.NoteDo not use this option for X Protocol operations.
Required
– Always use SSL. Deny connection if server does not support SSL.VerifyCA
– Always use SSL. Validate the certificate authorities (CA), but tolerate a name mismatch.VerifyFull
– Always use SSL. Fail if the host name is not correct.
-
tlsversion
,tls-version
,tls version
Default: A fallback solution decides which version of TLS to use.
Restricts the set of TLS protocol versions to use during the TLS handshake when both the client and server support the TLS versions indicated and the value of the
SslMode
connection-string option is not set toDisabled
orNone
(deprecated in Connector/NET 8.0.29). This option accepts a single version or a list of versions separated by a comma, for example,tls-version=TLSv1.2, TLSv1.3;
.Connector/NET supports the following values:
TLSv1.3
TLSv1.2
An error is reported when a value other than those listed is assigned. Likewise, an error is reported when an empty list is provided as the value, or if all of the versions in the list are unsupported and no connection attempt is made.
-
UserID
,User Id
,Username
,Uid
,User name
,User
Default:
null
The MySQL login account being used.
Options related to systems using a connection pool appear together
at the end of the list of general options (see
Connection-Pooling Options).
Connector/NET 8.0 exposes the options in this section as properties in
the
MySql.Data.MySqlClient.MySqlConnectionStringBuilder
class.
General Options. The Connector/NET options that follow are for general use with connection strings and the options apply to all MySQL server configurations:
-
AllowBatch
,Allow Batch
Default:
true
When
true
, multiple SQL statements can be sent with one command execution. Batch statements should be separated by the server-defined separator character.-
AllowLoadLocalInfile
,Allow Load Local Infile
Default:
false
Disables (by default) or enables the server functionality to load the data local infile. If this option is set to
true
, uploading files from any location is enabled, regardless of the path specified with theAllowLoadLocalInfileInPath
option.-
AllowLoadLocalInfileInPath
,Allow Load Local Infile In Path
Default:
null
Specifies a safe path from where files can be read and uploaded to the server. When the related
AllowLoadLocalInfile
option is set tofalse
, which is the default value, only those files from the safe path or any valid subfolder specified with theAllowLoadLocalInfileInPath
option can be loaded. For example, if/tmp
is set as the restricted folder, then file requests for/tmp/myfile
and/tmp/myfolder/myfile
can succeed. No relative paths or symlinks that fall outside of this path are permitted.The following table shows the behavior that results when the
AllowLoadLocalInfile
andAllowLoadLocalInfileInPath
connection string options are combined.AllowLoadLocalInfile Value AllowLoadLocalInfileInPath Value Behavior true
Empty string or null
valueAll uploads are permitted. true
A valid path All uploads are permitted (the path is not respected). false
Empty string or null
valueNo uploads are permitted. false
A valid path Only uploads from the specified folder and subfolder are permitted. -
AllowPublicKeyRetrieval
Default:
false
Setting this option to
true
informs Connector/NET that RSA public keys should be retrieved from the server and that connections using the classic MySQL protocol, when SSL is disabled, will fail by default. Exceptions to the default behavior can occur when previous successful connection attempts were made or when pooling is enabled and a pooled connection can be reused. This option was introduced with the 8.0.10 connector.CautionThis option is prone to man-in-the-middle attacks, so it should be used only in situations where you can ensure by other means that your connections are made to trusted servers.
-
AllowUserVariables
,Allow User Variables
Default:
false
Setting this to
true
indicates that the provider expects user variables in the SQL.-
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 8.0.10, 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.16, “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.16, “Character Set Considerations for Connector/NET” for usage details.
-
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.
-
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.-
DefaultAuthenticationPlugin
Takes precedence over the server-side default authentication plugin when a valid authentication plugin is specified (see Section 4.4.4, “Connector/NET Authentication”). The
Defaultauthenticationplugin
option is mandatory for supporting userless and passwordless Kerberos authentications in which the credentials are retrieved from a cache or the Key Distribution Center (KDC). For example:MySqlConnectionStringBuilder settings = new MySqlConnectionStringBuilder() { Server = "localhost", UserID = "", Password = "", Database = "mydb", Port = 3306, DefaultAuthenticationPlugin = "authentication_kerberos_client" };
If no value is set, the server-side default authentication plugin is used.
This option was introduced with the 8.0.26 connector.
-
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.
-
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.3, “Using Connector/NET with Table Caching”.-
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.-
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. See Section 4.5.7, “Working with Partial Trust / Medium Trust” for details.As of 8.0.10, this option is supported in .NET Core 2.0 implementations.
-
InteractiveSession
,Interactive
,Interactive Session
Default:
false
If set to
true
, the client is interactive. An interactive client is one in which the server variableCLIENT_INTERACTIVE
is set. If an interactive client is set, thewait_timeout
variable is set to the value ofinteractive_timeout
. The client session then times out after this period of inactivity. For more information, see Server System Variables in the MySQL Reference Manual.As of 8.0.10, 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.4.4, “Connector/NET Authentication”.Currently not supported for .NET Core implementations.
-
KerberosAuthMode
,kerberos auth mode
Default:
AUTO
On Windows, provides authentication support using Security Support Provider Interface (SSPI), which is capable of acquiring credentials from the Windows in-memory cache, and Generic Security Service Application Program Interface (GSSAPI) through the MIT Kerberos library. GSSAPI is capable of acquiring cached credentials previously generated using the kinit command. The default value for this option (
AUTO
) attempts to authenticate with GSSAPI if the authentication using SSPI fails.NoteThis option is permitted in Windows environments only. Using it in non-Windows environments produces an Option not supported exception.
Possible values for this connection option are:
AUTO
– Use SSPI and fall back to GSSAPI in case of failure.SSPI
– Use SSPI only and raise an exception in case of failure.GSSAPI
– Use GSSAPI only and raise an exception in case of failure. Always use theKRB5_CONFIG
andKRB5CCNAME
environment variables to specify configuration and cache locations when using GSSAPI through the MIT Kerberos library on Windows.
-
Logging
Default:
false
When the value is set to
true
, various pieces of information are sent to all configured trace listeners. For a more detailed description, see Section 4.5.12, “Connector/NET Tracing”.As of 8.0.10, this option is supported in .NET Core 2.0 implementations.
-
ociConfigFile
,OCI Config File
Defaults to one of the following path names:
~/.oci/config
on Linux and macOS host types%HOMEDRIVE%%HOMEPATH%\.oci\config
on Windows host types
If set, this option specifies an alternative location to the Oracle Cloud Infrastructure configuration file. Connector/NET 8.0.27 (and later) uses the Oracle Cloud Infrastructure SDK to obtain a fingerprint of the API key to use for authentication (
fingerprint
entry) and location of a PEM file with the private part of the API key (key_file
entry). The entries should be specified in the[DEFAULT]
profile. If the[DEFAULT]
profile is missing from the configuration file, Connector/NET locates the next profile to use instead.Not supported for .NET Framework 4.5.
x
implementations.-
OciConfigProfile
,OCI Config Profile
If set in Connector/NET 8.0.33 (or later), this option specifies which profile in an Oracle Cloud Infrastructure configuration file to use. The profile value defaults to the
DEFAULT
profile when no value is provided.Not supported for .NET Framework 4.5.
x
implementations.-
OldGuids
,Old Guids
Default:
false
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)
.-
OldGetStringBehavior
Default:
false
As of Connector/NET 8.3.0, calling the MySqlDataReader.GetString() method throws an
InvalidCastException
exception if the column is not a string type. All text types including char and varchar are allowed; and blob is not considered a text type.Setting this OldGetStringBehavior connection option to
true
restores previous behavior by logging a deprecation warning instead of throwing the exception.This option was added in 8.3.0 and removed in 9.0.0.
-
OpenIdIdentityToken
Default: ""
A Base64URL encoded string containing the OpenID Identity Token used to authenticate with the
authentication_openid_connect_client
authentication plugin.This option was added in 9.1.0.
-
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.ImportantFor MySQL 8.0.14 and later, 5.7.25 and later, and 5.6.43 and later, minimal permissions on named pipes are granted to clients that use them to connect to the server. However, Connector/NET can use named pipes only when granted full access on them. As a workaround, create a Windows local group containing the user that executes the client application. Restart the target server with the
named_pipe_full_access_group
system variable and specify the local group name as its value.Currently not supported for .NET Core implementations.
-
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).
-
Replication
Default:
false
Indicates if this connection is to use replicated servers.
As of 8.0.10, 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.-
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 between the[
and]
characters to work with Connector/NET. This option incurs a performance hit, so should only be used if necessary.-
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.3, “Using Connector/NET with Table Caching”.-
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. To convert only some of your BLOB columns, you can make use of the'BlobAsUTF8IncludePattern'
and'BlobAsUTF8ExcludePattern'
keywords. Set these to a regular expression pattern that matches the column names to include or exclude respectively.-
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.-
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.-
UsePerformanceMonitor
,Use Performance Monitor
,UserPerfMon
,PerfMon
Default:
false
Indicates that performance counters should be updated during execution.
Currently not supported for .NET Core implementations.
-
UseUsageAdvisor
,Use Usage Advisor
,Usage Advisor
Default:
false
Logs inefficient database operations.
As of 8.0.10, this option is supported in .NET Core 2.0 implementations.
Connection-Pooling Options. 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.-
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 option is useful in clustered configurations to force load balancing between a running server and a server just brought online. A value of zero (0) sets pooled connections to 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
,Max Pool Size
,Maximum Pool Size
,MaxPoolSize
Default:
100
The maximum number of connections allowed in the pool.
-
MinimumPoolSize
,Min Pool Size
,Minimum Pool Size
,MinPoolSize
Default:
0
The minimum number of connections allowed in the pool.
-
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
.
The connection options that follow are valid for connections made
with X Protocol. Connector/NET 8.0 exposes the options in this section
as properties in the
MySqlX.XDevAPI.MySqlXConnectionStringBuilder
class.
-
Auth
,Authentication
,Authentication Mode
Authentication mechanism to use with the X Protocol. This option was introduced with the 8.0.9 connector and has the following values, which are not case-sensitive:
MYSQL41
,PLAIN
, andEXTERNAL
. If theAuth
option is not set, the mechanism is chosen depending on the connection type.PLAIN
is used for secure connections (TLS or Unix sockets) andMYSQL41
is used for unencrypted connections.EXTERNAL
is used for external authentication methods such as PAM, Windows login IDs, LDAP, or Kerberos. (EXTERNAL
is not currently supported.)The
Auth
option is not supported for classic MySQL protocol connections and returnsNotSupportedException
if used.-
Compression
,use-compression
Default:
preferred
Compression is used to send and receive data when both the client and server support it for X Protocol connections and the client requests compression using this option. After a successful algorithm negotiation is made, Connector/NET can start compressing data immediately. To prevent the compression of small data packets, or of data already compressed, Connector/NET defines a size threshold of 1000 bytes.
When multiple compression algorithms are supported by the server, Connector/NET applies the following priority by default:
zstd_stream
(first),lz4_message
(second), anddeflate_stream
(third). Thedeflate_stream
algorithm is supported for use with .NET Core, but not for .NET Framework.TipUse the
compression-algorithms
option to specify one ore more supported algorithms in a different order. The algorithms are negotiated in the order provided by client. For usage details, see thecompression-algorithms
option.Data compression for X Protocol connections was added in the Connector/NET 8.0.20 release. The
Compression
option accepts the following values:preferred
to apply data compression if the server supports the algorithms chosen by the client. Otherwise, the data is sent and received without compression.required
to ensure that compression is used or to terminate the connection and return an error message.disabled
to prevent data compression.
-
compression-algorithms
,CompressionAlgorithms
As of Connector/NET 8.0.22, a client application can specify the order in which supported compression algorithms are negotiated with the server. The value of the
Compression
connection option must be set topreferred
or torequired
for this option to apply. Unsupported algorithms are ignored.This option accepts the following algorithm names and synonyms:
lz4_message
orlz4
zstd_stream
orzstd
deflate_stream
ordeflate
(not valid with .NET Framework)
Algorithm names and synonyms can be combined in a comma-separated list or provided as a standalone value (with or without brackets). Examples:
// Compression option set to preferred (default) MySQLX.GetSession("mysqlx://test:test@localhost:3306?compression-algorithms=[lz4_message,deflate] MySQLX.GetSession("mysqlx://test:test@localhost:3306?compressionalgorithms=lz4 MySQLX.GetSession("mysqlx://test:test@localhost:3306?compression=preferred&compression-algorithms=[zstd] // Compression option set to required MySQLX.GetSession("mysqlx://test:test@localhost:3306?compression=required&compression-algorithms=[zstd_stream,lz4_message] MySQLX.GetSession("mysqlx://test:test@localhost:3306?compression=required&compression-algorithms=[lz4] MySQLX.GetSession("mysqlx://test:test@localhost:3306?compression=required&compression-algorithms=zstd_stream // Connection string MySQLX.GetSession("server=localhost;port=3306;uid=test;password=test;compression=required;compression-algorithms=lz4_message;") // Anonymous object MySQLX.GetSession(new { server = "localhost", port = "3306", uid = "test", password = "test", compression="required", compressionalgorithms = "deflate_stream" })
For additional information, see Connection Compression with X Plugin.
-
connection-attributes
,ConnectionAttributes
Default:
true
This option was introduced in Connector/NET 8.0.16 for submitting a set of attributes to be passed together with default connection attributes to the server. The aggregate size of connection attribute data sent by a client is limited by the value of the
performance_schema_session_connect_attrs_size
server variable. The total size of the data package should be less than the value of the server variable. For general information about connection attributes, see Performance Schema Connection Attribute Tables.The connection-attributes parameter value can be empty (the same as specifying
true
), a Boolean value (true
orfalse
to enable or disable the default attribute set), or a list or zero or morekey=value
specifiers separated by commas (to be sent in addition to the default attribute set). Within a list, a missing key value evaluates as theNULL
value. Examples:// Sessions MySQLX.GetSession($"mysqlx://user@host/schema") MySQLX.GetSession($"mysqlx://user@host/schema?connection-attributes") MySQLX.GetSession($"mysqlx://user@host/schema?connection-attributes=true") MySQLX.GetSession($"mysqlx://user@host/schema?connection-attributes=false") MySQLX.GetSession($"mysqlx://user@host/schema?connection-attributes=[attr1=val1,attr2,attr3=]") MySQLX.GetSession($"mysqlx://user@host/schema?connection-attributes=[]") // Pooling MySQLX.GetClient($"mysqlx://user@host/schema") MySQLX.GetClient($"mysqlx://user@host/schema?connection-attributes") MySQLX.GetClient($"mysqlx://user@host/schema?connection-attributes=true") MySQLX.GetClient($"mysqlx://user@host/schema?connection-attributes=false") MySQLX.GetClient($"mysqlx://user@host/schema?connection-attributes=[attr1=val1,attr2,attr3=]") MySQLX.GetClient($"mysqlx://user@host/schema?connection-attributes=[]")
Application-defined attribute names cannot begin with
_
because such names are reserved for internal attributes.If connection attributes are not specified in a valid way, an error occurs and the connection attempt fails.
-
Connect-Timeout
,ConnectTimeout
Default:
10000
The length of time (in milliseconds) to wait for an X Protocol connection to the server before terminating the attempt and generating an error. You can disable the connection timeout by setting the value to zero. This option can be specified as follows:
URI-like connection string example
MySQLX.GetSession("mysqlx://test:test@localhost:33060?connect-timeout=2000");
Connection string example
MySQLX.GetSession("server=localhost;user=test;port=33060;connect-timeout=2000");
Anonymous object example
MySQLX.GetSession(new { server="localhost", user="test", port=33060, connecttimeout=2000 });
MySqlXConnectionStringBuilder
class examplevar builder = new MySqlXConnectionStringBuilder("server=localhost;user=test;port=33060"); builder.ConnectTimeout = 2000; MySQLX.GetSession(builder.ConnectionString);
-
SslCrl
,Ssl-Crl
Default:
null
Path to a local file containing certificate revocation lists.
ImportantAlthough the
SslCrl
connection-string option is valid for use, applying it raises aNotSupportedException
message.