MySQL ODBC connection string parameters

The following table describes the key connection string parameters for connecting to MySQL via the ODBC driver.

Basic settings

Parameter Description
Server The host name or IP address of the MySQL server.
Port The port number for the connection. The default value is 3306.
User ID The MySQL username.
Password The MySQL password.
Database The name of the database to connect to.

Advanced settings

Parameter Description
Allow NULL strings Allows NULL values to be passed to metadata retrieval functions, ensuring compatibility with third-party tools that send NULL where the ODBC specification requires a value.
AnsiQuotesMode Specifies how the ANSI_QUOTES value is handled in the sql_mode variable. The possible values are:
  • Allow – Forcefully includes the ANSI_QUOTES value in the sql_mode variable regardless of the value on the server.
  • Denied – Forcefully excludes the ANSI_QUOTES value in the sql_mode variable regardless of the value on the server.
  • Default – Uses the ANSI_QUOTES value of the sql_mode variable regardless of the value on the server.
Charset Specifies the character set used by the driver when reading and writing character data.
Compress Enables data compression during transfer. Compression can improve performance over slow connections, especially when working with large result sets, because each row is compressed independently. In some scenarios, however, compression may reduce fetch speed. The default value is False.
Connection Timeout Specifies the time (in seconds) to wait for a connection to open before terminating an attempt. The default value is 15.
Empty strings as NULL Treats empty strings as NULL values when passed to metadata retrieval functions, ensuring compatibility with third-party tools that pass empty strings instead of NULL.
Interactive Enables interactive client mode, which uses interactive_timeout instead of wait_timeout for connection inactivity periods. When enabled, the client’s session wait_timeout variable is set to the value of the session interactive_timeout variable. The default value is false.
IP Version Specifies the Internet Protocol version to use for the connection. The possible values are:
  • ivIPv4 – (Default) Uses Internet Protocol Version 4 (IPv4).
  • ivIPv6 – Uses Internet Protocol Version 6 (IPv6).
  • ivIPBoth – Uses either Internet Protocol Version 6 (IPv6) or Version 4 (IPv4). If IPv6 is enabled in the operating system, a connection attempt is made via IPv6; if it fails, a new connection attempt is made via IPv4.
Mapping TimeStamp as VarChar Used to convert TIMESTAMP values to VARCHAR values. The default value is False.
ODBC Behavior Specifies the ODBC specification version the driver must conform to, based on the expectations of a third-party tool.
Typically, the driver’s behavior is controlled by setting the SQL_ATTR_ODBC_VERSION attribute via the SQLSetEnvAttr function. However, some third-party tools expect the driver to behave according to ODBC 2.x standards, but either fail to set this attribute or pass an incorrect value.
In such cases, you can explicitly define the required behavior in the connection string using the ODBC Behavior parameter. Available values:
  • Default – Uses the default behavior as determined by the third-party tool.
  • Ver 2.x – Forces the driver to use ODBC 2.x behavior.
  • Ver 3.x – Forces the driver to use ODBC 3.x behavior.
Query Timeout Used to specify the number of seconds that the execution of an SQL query can take before it is terminated and an exception is raised. If the value is 0, no timeout will happen. The default value is 0.
ReadOnly Used to prevent data from being modified, if set to True. Server version 5.6.5 or later is supported. The default value is False.
RegionalDateTimeSettings Enables the use of local regional settings when converting dates and times to strings.
RegionalNumberSettings Enables the use of local regional settings when converting numbers to strings.
String Types Sets the string value types returned by the driver as Default, Ansi or Unicode:
  • Default – The driver defines the string types.
  • Ansi – All string types will be returned as SQL_CHAR, SQL_VARCHAR and SQL_LONGVARCHAR.
  • Unicode – All string types will be returned as SQL_WCHAR, SQL_WVARCHAR and SQL_WLONGVARCHAR.
UseUnicode Enables Unicode (UTF-8) support for string data. The default value is False.

Sample connection string

DRIVER={Devart ODBC Driver for MySQL};User ID=myUsername;Password=myPassword;Server=myServer;Database=myDatabase