Documentation Home
MySQL Connector/ODBC Developer Guide
Related Documentation Download this Manual

MySQL Connector/ODBC Developer Guide  /  Configuring Connector/ODBC  /  Connector/ODBC Connection Parameters

5.2 Connector/ODBC Connection Parameters

You can specify the parameters in the following tables for Connector/ODBC when configuring a DSN:

Users on Windows can use the ODBC Data Source Administrator to set these parameters; see Section 5.3, “Configuring a Connector/ODBC DSN on Windows” on how to do that, and see Table 5.1, “Connector/ODBC DSN Configuration Options” for information on the options and the fields and check boxes they corrrespond to on the graphical user interface of the ODBC Data Source Administrator. On Unix and macOS, use the parameter name and value as the keyword/value pair in the DSN configuration. Alternatively, you can set these parameters within the InConnectionString argument in the SQLDriverConnect() call.

Table 5.1 Connector/ODBC DSN Configuration Options

Parameter GUI Option Default Value Comment
user User ODBC The user name used to connect to MySQL.
uid User ODBC Synonymous with user. Added in 3.51.16.
server TCP/IP Server localhost The host name of the MySQL server.
database Database - The default database.
option - 0 Options that specify how Connector/ODBC works. See Table 5.3, “Connector/ODBC Option Parameters” and Table 5.4, “Recommended Connector/ODBC Option Values for Different Configurations”.
port Port 3306 The TCP/IP port to use if server is not localhost.
initstmt Initial Statement - Initial statement. A statement to execute when connecting to MySQL. In version 3.51 the parameter is called stmt. The driver supports the initial statement being executed only at the time of the initial connection.
password Password - The password for the user account on server.
pwd Password - Synonymous with password. Added in 3.51.16.
socket - - The Unix socket file or Windows named pipe to connect to if server is localhost.
sslca SSL Certificate - The path to a file with a list of trust SSL CAs. Added in 3.51.16.
sslcapath SSL CA Path - The path to a directory that contains trusted SSL CA certificates in PEM format. Added in 3.51.16.
sslcert SSL Certificate - The name of the SSL certificate file to use for establishing a secure connection. Added in 3.51.16.
sslcipher SSL Cipher - The list of permitted ciphers for SSL encryption. The cipher list has the same format as the openssl ciphers command. Added in 3.51.16.
sslkey SSL Key - The name of the SSL key file to use for establishing a secure connection. Added in 3.51.16.
rsakey RSA Public Key - The full-path name of the PEM file that contains the RSA public key for using the SHA256 authentication plugin of MySQL. Added in 5.3.4.
sslverify Verify SSL 0 If set to 1, the SSL certificate will be verified when used with the MySQL connection. If not set, then the default behavior is to ignore SSL certificate verification.
Note

The option has been deprecated since 5.3.7. It is preferable to use the SSLMODE option parameter instead.

charset Character Set - The character set to use for the connection. Added in 3.51.17.
readtimeout - - The timeout in seconds for attempts to read from the server. Each attempt uses this timeout value and there are retries if necessary, so the total effective timeout value is three times the option value. You can set the value so that a lost connection can be detected earlier than the TCP/IP Close_Wait_Timeout value of 10 minutes. This option works only for TCP/IP connections, and only for Windows prior to MySQL 5.1.12. Corresponds to the MYSQL_OPT_READ_TIMEOUT option of the MySQL Client Library. Added in 3.51.27.
writetimeout - - The timeout in seconds for attempts to write to the server. Each attempt uses this timeout value and there are net_retry_count retries if necessary, so the total effective timeout value is net_retry_count times the option value. This option works only for TCP/IP connections, and only for Windows prior to MySQL 5.1.12. Corresponds to the MYSQL_OPT_WRITE_TIMEOUT option of the MySQL Client Library. Added in 3.51.27.
interactive Interactive Client 0 If set to 1, the CLIENT_INTERACTIVE connection option of mysql-real-connect() is enabled. Added in 5.1.7.
prefetch Prefetch from server by _ rows at a time 0

When set to a non-zero value N, causes all queries in the connection to return N rows at a time rather than the entire result set. Useful for queries against very large tables where it is not practical to retrieve the whole result set at once. You can scroll through the result set, N records at a time.

This option works only with forward-only cursors. It does not work when the option parameter MULTI_STATEMENTS is set. It can be used in combination with the option parameter NO_CACHE. Its behavior in ADO applications is undefined: the prefetching might or might not occur. Added in 5.1.11.

no_ssps - 0

In Connector/ODBC 5.2 and after, by default, server-side prepared statements are used. When this option is set to a non-zero value, prepared statements are emulated on the client side, which is the same behavior as in 5.1 and 3.51. Added in 5.2.0.

can_handle_exp_pwd Can Handle Expired Password 0 Indicates that the application can deal with an expired password, which is signalled by an SQL state of 08004 (Server rejected the connection) and a native error code ER_MUST_CHANGE_PASSWORD_LOGIN (1862). The connection is sandboxed, and can do nothing other than issue a SET PASSWORD statement. To establish a connection in this case, your application must either use the initstmt connection option to set a new password at the start, or issue a SET PASSWORD statement immediately after connecting. Once the expired password is reset, the restrictions on the connection are lifted. See ALTER USER Syntax for details about password expiration for MySQL server accounts. Added in 5.2.4.
ENABLE_CLEARTEXT_PLUGIN Enable Cleartext Authentication 0 Set to 1 to enable cleartext authentication. Added in 5.1.13 and 5.2.5.
GET_SERVER_PUBLIC_KEY Get Server Public Key 0

For connections, Connector/ODBC requests the RSA public key from the server. For accounts that use the caching_sha2_password or sha256_password authentication plugin, this key can be used during the connection process for RSA key-pair based password exchange with TLS disabled. This option corresponds to the MYSQL_OPT_GET_SERVER_PUBLIC_KEY option for the mysql_options() C API function. The value is a boolean, and added in 8.0.11.

This capability requires a MySQL 8 server, and is supported only for Connector/ODBC built using OpenSSL. This option is ignored when used with MySQL 5.7.

NO_TLS_1_0 Disable TLS 1.0 0 Disallows the use of TLS 1.0 for connection encryption. All versions of TLS are allowed by default, and this option excludes version 1.0 from being used. Added in 5.3.7.
NO_TLS_1_1 Disable TLS 1.1 0 Disallows the use of TLS 1.1 for connection encryption. All versions of TLS are allowed by default, and this option exudes version 1.1 from being used. Added in 5.3.7.
NO_TLS_1_2 Disable TLS 1.2 0 Disallows the use of TLS 1.2 for connection encryption. All versions of TLS are allowed by default, and this option exudes version 1.1 from being used. Added in 5.3.7.
SSL_ENFORCE Enforce SSL 0 Enforce the requirement to use SSL for connections to server. See Table 5.2, “Combined Effects of SSL_ENFORCE and DISABLE_SSL_DEFAULT ”. Added in 5.3.6.
Note

The option has been deprecated since 5.3.7. It is preferable to use the SSLMODE option parameter instead.

DISABLE_SSL_DEFAULT Disable default SSL 0 Disable the default requirement to use SSL for connections to server. When set to 0 [default], Connector/ODBC tries to connect with SSL first, and falls back to unencrypted connection if it is not possible to establish an SSL connection. When set to 1, Connection with SSL is not attempted, and unencrypted connection is used, unless SSL_ENFORCE is also set to 1. See Table 5.2, “Combined Effects of SSL_ENFORCE and DISABLE_SSL_DEFAULT ”. Added in 5.3.6.
Note

The option has been deprecated since 5.3.7. It is preferable to use the SSLMODE option parameter instead.

SSLMODE SSL Mode -

Sets the SSL mode of the server connection. The option can be set to any of the following values: DISABLED, PREFERRED, REQUIRED, VERIFY_CA, or VERIFY_IDENTITY. See description for the --ssl-mode option in the MySQL 5.7 Reference Manual for the meaning of each of the option values.

If SSLMODE is not explicitly set, use of the sslca or sslcapath option implies SSLMODE=VERIFY_CA.

Added in 5.3.7. This option overrides the deprecated sslverify and SSL_ENFORCE options.


Note

The SSL configuration parameters can also be automatically loaded from a my.ini or my.cnf file. See Using Option Files.

Table 5.2 Combined Effects of SSL_ENFORCE and DISABLE_SSL_DEFAULT

DISABLE_SSL_DEFAULT = 0 DISABLE_SSL_DEFAULT = 1
SSL_ENFORCE = 0 (Default) Connection with SSL is attempted first; if not possible, fall back to unencrypted connection. Connection with SSL is not attempted; use unencrypted connection.
SSL_ENFORCE = 1 Connect with SSL; throw an error if an SSL connection cannot be established. Connect with SSL; throw an error if an SSL connection cannot be established. DISABLE_SSL_DEFAULT=1 is overridden.

The behavior of Connector/ODBC can be also modified by using special option parameters listed in Table 5.3, “Connector/ODBC Option Parameters”, specified in the connection string or through the GUI dialog box. All of the connection parameters also have their own numeric constant values, which can be added up as a combined value for the option parameter for specifying those options. However, the numerical option value in the connection string can only enable, but not disable parameters enabled on the DSN, which can only be overridden by specifying the option parameters using their text names in the connection string.

Note

While the combined numerical value for the option parameter can be easily constructed by addition of the options' constant values, decomposing the value to verify if particular options are enabled can be difficult. We recommend using the options' parameter names instead in the connection string, because they are self-explanatory.

Table 5.3 Connector/ODBC Option Parameters

Parameter Name GUI Option Constant Value Description
FOUND_ROWS Return matched rows instead of affected rows 2 The client cannot handle when MySQL returns the true value of affected rows. If this flag is set, MySQL returns found rows instead. You must have MySQL 3.21.14 or newer for this to work.
BIG_PACKETS Allow big result set 8 Do not set any packet limit for results and bind parameters. Without this option, parameter binding will be truncated to 255 characters.
NO_PROMPT Don't prompt when connecting 16 Do not prompt for questions even if driver would like to prompt.
DYNAMIC_CURSOR Enable Dynamic Cursors 32 Enable or disable the dynamic cursor support.
NO_SCHEMA Ignore schema in column specifications 64 Ignore use of database name in db_name.tbl_name.col_name.
NO_DEFAULT_CURSOR Disable driver-provided cursor support 128 Force use of ODBC manager cursors (experimental).
NO_LOCALE Don't use setlocale() 256 Disable the use of extended fetch (experimental).
PAD_SPACE Pad CHAR to full length with space 512 Pad CHAR columns to full column length.
FULL_COLUMN_NAMES Include table name in SQLDescribeCol() 1024 SQLDescribeCol() returns fully-qualified column names.
COMPRESSED_PROTO Use compression 2048 Use the compressed client/server protocol.
IGNORE_SPACE Ignore space after function names 4096 Tell server to ignore space after function name and before ( (needed by PowerBuilder). This makes all function names keywords.
NAMED_PIPE Named Pipe 8192 Connect with named pipes to a mysqld server running on NT.
NO_BIGINT Treat BIGINT columns as INT columns 16384 Change BIGINT columns to INT columns (some applications cannot handle BIGINT).
NO_CATALOG Disable catalog support 32768 Forces results from the catalog functions, such as SQLTables, to always return NULL and the driver to report that catalogs are not supported.
USE_MYCNF Read options from my.cnf 65536 Read parameters from the [client] and [odbc] groups from my.cnf.
SAFE Enable safe options 131072 Add some extra safety checks.
NO_TRANSACTIONS Disable transaction support 262144 Disable transactions.
LOG_QUERY Log queries to %TEMP%\myodbc.sql 524288 Enable query logging to c:\myodbc.sql(/tmp/myodbc.sql) file. (Enabled only in debug mode.)
NO_CACHE Don't cache results of forward-only cursors 1048576 Do not cache the results locally in the driver, instead read from server (mysql_use_result()). This works only for forward-only cursors. This option is very important in dealing with large tables when you do not want the driver to cache the entire result set.
FORWARD_CURSOR Force use of forward-only cursors 2097152 Force the use of Forward-only cursor type. In cases of applications setting the default static/dynamic cursor type and one wants the driver to use noncache result sets, this option ensures the forward-only cursor behavior.
AUTO_RECONNECT Enable automatic reconnect 4194304 Enables auto-reconnection functionality. Do not use this option with transactions, since an auto-reconnection during a incomplete transaction may cause corruption. An auto-reconnected connection will not inherit the same settings and environment as the original connection. Added in 3.51.13.
AUTO_IS_NULL Enable SQL_AUTO_IS_NULL 8388608

When AUTO_IS_NULL is set, the driver does not change the default value of sql_auto_is_null, leaving it at 1, so you get the MySQL default, not the SQL standard behavior.

When AUTO_IS_NULL is not set, the driver changes the default value of SQL_AUTO_IS_NULL to 0 after connecting, so you get the SQL standard, not the MySQL default behavior.

Thus, omitting the flag disables the compatibility option and forces SQL standard behavior.

See IS NULL. Added in 3.51.13.

ZERO_DATE_TO_MIN Return SQL_NULL_DATA for zero date 16777216 Translates zero dates (XXXX-00-00) into the minimum date values supported by ODBC, XXXX-01-01. This resolves an issue where some statements will not work because the date returned and the minimum ODBC date value are incompatible. Added in 3.51.17.
MIN_DATE_TO_ZERO Bind minimal date as zero date 33554432 Translates the minimum ODBC date value (XXXX-01-01) to the zero date format supported by MySQL (XXXX-00-00). This resolves an issue where some statements will not work because the date returned and the minimum ODBC date value are incompatible. Added in 3.51.17.
NO_DATE_OVERFLOW Ignore data overflow error 0 Continue with the query execution rather then return error if the time portion is missing. The server will ignore the time component and the result is the same as if they were zeros. Added in 5.3.8.
MULTI_STATEMENTS Allow multiple statements 67108864 Enables support for batched statements. Added in 3.51.18.
COLUMN_SIZE_S32 Limit column size to signed 32-bit range 134217728 Limits the column size to a signed 32-bit value to prevent problems with larger column sizes in applications that do not support them. This option is automatically enabled when working with ADO applications. Added in 3.51.22.
NO_BINARY_RESULT Always handle binary function results as character data 268435456 When set, this option disables charset 63 for columns with an empty org_table. Added in 3.51.26.
DFLT_BIGINT_BIND_STR Bind BIGINT parameters as strings 536870912 Causes BIGINT parameters to be bound as strings. Microsoft Access treats BIGINT as a string on linked tables. The value is read correctly, but bound as a string. This option is used automatically if the driver is used by Microsoft Access. Added in 5.1.3.
NO_INFORMATION_SCHEMA Don't use INFORMATION_SCHEMA for metadata 1073741824 Tells catalog functions not to use INFORMATION_SCHEMA, but rather use legacy algorithms. The trade-off here is usually speed for information quality. Using INFORMATION_SCHEMA is often slow, but the information obtained is more complete. Added in 5.1.7.

Table 5.4, “Recommended Connector/ODBC Option Values for Different Configurations” shows some recommended parameter settings and their corresponding option values for various configurations:

Table 5.4 Recommended Connector/ODBC Option Values for Different Configurations

Configuration Parameter Settings Option Value
Microsoft Access, Visual Basic FOUND_ROWS=1; 2
Microsoft Access (with improved DELETE queries) FOUND_ROWS=1;DYNAMIC_CURSOR=1; 34
Microsoft SQL Server COLUMN_SIZE_S32=1; 134217728
Large tables with too many rows COMPRESSED_PROTO=1; 2048
Sybase PowerBuilder IGNORE_SPACE=1;FLAG_SAFE=1; 135168
Query log generation (Debug mode) LOG_QUERY=1; 524288
Large tables with no-cache results NO_CACHE=1;FORWARD_CURSOR=1; 3145728
Applications that run full-table "SELECT * FROM ... " query, but read only a small number (N) of rows from the result PREFETCH=N Not Applicable


User Comments
Sign Up Login You must be logged in to post a comment.