(MySql)Connection strings

文档地址:http://dev.mysql.com/doc/refman/5.6/en/connector-net-connection-options.html

General Options
NameDefaultDescription
Allow BatchAllowBatchtrueWhen 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,AllowUserVariablesfalseSetting 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,AllowZeroDateTimefalseIf set to TrueMySqlDataReader.GetValue() returns a MySqlDateTime object for date or datetime columns that have disallowed values, such as zero datetime values, and a System.DateTime object for valid values. If set to False (the default setting) it will cause a System.DateTime object to be returned for all legal values and an exception to be thrown for disallowed values, such as zero datetime values.
Auto EnlistAutoEnlisttrueIf AutoEnlist is set to true, which is the default, a connection opened using TransactionScopeparticipates in this scope, it commits when the scope commits and rolls back if TransactionScope does not commit. However, this feature is considered security sensitive and therefore cannot be used in a medium trust environment.
BlobAsUTF8ExcludePatternnullA POSIX-style regular expression that matches the names of BLOB columns that do not contain UTF-8 character data. See Section 20.2.5.15, “Character Set Considerations for Connector/Net” for usage details.
BlobAsUTF8IncludePatternnullA POSIX-style regular expression that matches the names of BLOB columns containing UTF-8 character data. See Section 20.2.5.15, “Character Set Considerations for Connector/Net” for usage details.
Certificate File,CertificateFilenullThis option specifies the path to a certificate file in PKCS #12 format (.pfx). For an example of usage, seeSection 20.2.4.7, “Tutorial: Using SSL with MySQL Connector/Net”. Was introduced with 6.2.1.
Certificate Password,CertificatePasswordnullSpecifies a password that is used in conjunction with a certificate specified using the optionCertificateFile. For an example of usage, see Section 20.2.4.7, “Tutorial: Using SSL with MySQL Connector/Net”. Was introduced with 6.2.1.
Certificate Store Location,CertificateStoreLocationnullEnables 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 20.2.4.7, “Tutorial: Using SSL with MySQL Connector/Net”. Was introduced with 6.2.1.
Certificate Thumbprint,CertificateThumbprintnullSpecifies a certificate thumbprint to ensure correct identification of a certificate contained within a personal store. For an example of usage, see Section 20.2.4.7, “Tutorial: Using SSL with MySQL Connector/Net”. Was introduced with 6.2.1.
CharSetCharacter Set,CharacterSet 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 result data.
Check Parameters,CheckParameterstrueIndicates if stored routine parameters should be checked against the server.
Command Interceptors,CommandInterceptors The list of interceptors that can intercept SQL command operations.
Connect Timeout,Connection Timeout,ConnectionTimeout15The length of time (in seconds) to wait for a connection to the server before terminating the attempt and generating an error.
Convert Zero Datetime,ConvertZeroDateTimefalseTrue to have MySqlDataReader.GetValue() and MySqlDataReader.GetDateTime() returnDateTime.MinValue for date or datetime columns that have disallowed values.
Default Command Timeout,DefaultCommandTimeout30Sets 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
Default Table Cache Age,DefaultTableCacheAge60Specifies how long a TableDirect result should be cached, in seconds. For usage information about table caching, see Section 20.2.5.6, “Using Connector/Net with Table Caching”. This option was added in Connector/Net 6.4.
EncryptUseSSLfalseFor 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 truefalseyes, 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. The option still works if used. If this option is set to true, it is equivalent to SSL Mode = Preferred.
Exception Interceptors,ExceptionInterceptors The list of interceptors that can triage thrown MySqlException exceptions.
Functions Return String,FunctionsReturnStringfalseCauses the connector to return binary/varbinary values as strings, if they do not have a tablename in the metadata.
HostServerData Source,DataSourceAddressAddr,Network AddresslocalhostThe 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 will be 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.
Ignore Prepare,IgnorePreparetrueWhen true, instructs the provider to ignore any calls to MySqlCommand.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 added in Connector/Net 5.0.3 and Connector/Net 1.0.9.
Initial CatalogDatabasemysqlThe case-sensitive name of the database to use initially.
InteractiveInteractive Session,InteractiveSessionfalseIf 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, the wait_timeout variable is set to the value of interactive_timeout. The client will then timeout after this period of inactivity. More details can be found in the server manual Section 5.1.3, “Server System Variables”.
Integrated Security,IntegratedSecuritynoUse Windows authentication when connecting to server. By default, it is turned off. To enable, specify a value of yes. (You can also use the value sspi as an alternative to yes.) For details, see Section 20.2.5.5, “Using the Windows Native Authentication Plugin”. This option was introduced in Connector/Net 6.4.4.
Keep AliveKeepalive0For 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.
LoggingfalseWhen true, various pieces of information is output to any configured TraceListeners. See Section 20.2.5.13, “Using the MySQL Connector/Net Trace Source Object” for further details.
Old GuidsOldGuidsfalseThis 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 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).
Old SyntaxOldSyntaxUse Old SyntaxUseOldSyntaxfalseThis option was deprecated in Connector/Net 5.2.2. All code should now be written using the '@' symbol as the parameter marker.
Passwordpwd The password for the MySQL account being used.
Persist Security Info,PersistSecurityInfofalseWhen 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 aretruefalseyes, and no.
Pipe NamePipePipeNamemysqlWhen set to the name of a named pipe, the MySqlConnection will attempt to connect to MySQL on that named pipe. This setting only applies to the Windows platform.
Port3306The port MySQL is using to listen for connections. This value is ignored if Unix socket is used.
Procedure Cache Size,ProcedureCacheSize,procedure cache,procedurecache25Sets 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 added in Connector/Net 5.0.2 and Connector/Net 1.0.9.
ProtocolConnection Protocol,ConnectionProtocolsocketSpecifies 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.
ReplicationfalseIndicates if this connection is to use replicated servers.
Respect Binary Flags,RespectBinaryFlagstrueSetting this option to false means that Connector/Net ignores a column's binary flags as set by the server. This option was added in Connector/Net version 5.1.3.
Shared Memory Name,SharedMemoryNameMYSQLThe name of the shared memory object to use for communication if the connection protocol is set tomemory.
Sql Server Mode,sqlservermodefalseAllow 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 added in version 6.3.1.
SSL ModeSslModeNoneThis 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 MySQL Connector/Net 6.2.1.

Table Cachetablecache,tablecachingfalseEnables or disables caching of TableDirect commands. A value of true enables the cache whilefalse disables it. For usage information about table caching, see Section 20.2.5.6, “Using Connector/Net with Table Caching”. This option was added in Connector/Net 6.4.
Treat BLOBs as UTF8,TreatBlobsAsUTF8false 
Treat Tiny As Boolean,TreatTinyAsBooleantrueSetting this value to false indicates that TINYINT(1) will be treated as an INT. See Section 10.1.1, “Numeric Type Overview” for a further explanation of the TINYINT and BOOL data types.
Use Affected Rows,UseAffectedRowsfalseWhen 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,UseProcedureBodies,procedure bodiestrueWhen set to true, the default value, MySQL Connector/Net expects the body of the procedure to be viewable. This enables it to determine the parameter types and order. Set the option to false when the user connecting to the database does not have the SELECT privileges for the mysql.proc (stored procedures) table, or cannot view INFORMATION_SCHEMA.ROUTINES. In this case, MySQL Connector/Net cannot determine the types and order of the parameters, and must be alerted to this fact by setting this option to false. When set to false, MySQL Connector/Net does not rely on this information being available when the procedure is called. Because MySQL Connector/Net will not be able to determine this information, 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 added in MySQL Connector/Net 5.0.4 and MySQL Connector/Net 1.0.10.
User IdUserIDUsername,UidUser nameUser The MySQL login account being used.
CompressUse Compression,UseCompressionfalse

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.

Use Usage AdvisorUsage AdvisorUseUsageAdvisorfalseLogs inefficient database operations.
Use Performance Monitor,UsePerformanceMonitor,userperfmonperfmonfalseIndicates that performance counters should be updated during execution.
 
Connection Pooling Options
NameDefaultDescription
Cache Server Properties,CacheServerPropertiesfalseSpecifies 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 will not be informed of any changes to configuration variables made by other connections. This option was added in Connector/Net 6.3.
Connection Lifetime,ConnectionLifeTime0When 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.
Connection Reset,ConnectionResetfalseIf true, the connection state will be 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.
Maximum Pool SizeMax Pool Size,maximumpoolsize100The maximum number of connections allowed in the pool.
Minimum Pool SizeMin Pool Size,MinimumPoolSize0The minimum number of connections allowed in the pool.
PoolingtrueWhen true, the MySqlConnection object is drawn from the appropriate pool, or if necessary, is created and added to the appropriate pool. Recognized values are truefalseyes, and no.
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值