This is a read-only copy of the MariaDB Knowledgebase generated on 2024-11-21. For the latest, interactive version please visit https://mariadb.com/kb/.

About MariaDB Connector/ODBC

MariaDB Connector/ODBC is a database driver that uses the industry standard Open Database Connectivity (ODBC) API. Some of the key features of the driver are:

  • It is LGPL-licensed.
  • It is compliant with the ODBC 3.5 standard.
  • It can be used as a drop-in replacement for MySQL Connector/ODBC.
  • It supports both Unicode and ANSI modes.
  • It primarily uses the MariaDB/MySQL binary protocol (i.e. server-side prepared statements).

The current release series are:

  • MariaDB Connector/ODBC 3.1 is the current stable release series.
  • MariaDB Connector/ODBC 3.0 and 2.0 are both previous stable release series.

Recent Releases

The most recent Stable (GA) release of MariaDB Connector/ODBC is:
MariaDB Connector/ODBC 3.2.4

DateReleaseStatusRelease NotesChangelog
14 Nov 2024MariaDB Connector/ODBC 3.2.4Stable (GA)Release NotesChangelog
26 Aug 2024MariaDB Connector/ODBC 3.2.3Stable (GA)Release NotesChangelog
18 Jun 2024MariaDB Connector/ODBC 3.2.2Stable (GA)Release NotesChangelog
4 Dec 2023MariaDB Connector/ODBC 3.1.20Stable (GA)Release NotesChangelog
7 Jul 2023MariaDB Connector/ODBC 3.1.19Stable (GA)Release NotesChangelog

see all releases

Installing MariaDB Connector/ODBC

MariaDB Connector/ODBC packages can be downloaded by selecting your desired version from the following page:

MariaDB Connector/ODBC packages can also be downloaded by selecting ODBC connector as the Product on the following page:

See the instructions below for information on how to install the MariaDB Connector/ODBC package for your operating system.

Installing MariaDB Connector/ODBC on Windows

To install MariaDB Connector/ODBC on Windows, we distribute MSI packages. The MSI installation process is fairly straightforward.

MariaDB Connector/ODBC supports the built-in ODBC Driver Manager on Windows, so nothing else needs to be installed. The MSI installation process will even take care of registering MariaDB Connector/ODBC with the ODBC Driver Manager, so that it is ready to use immediately.

It is generally a good idea to download and install both the 32-bit and 64-bit MSI packages. Otherwise, the ODBC Driver Manager may sometimes load the wrong version of the driver for your application, which can cause errors like the following:

[Microsoft][ODBC Driver Manager] The specified DSN contains an
 architecture mismatch between the Driver and Application.

Installing MariaDB Connector/ODBC on Linux

To install MariaDB Connector/ODBC on Linux, we currently only distribute binary tarball packages.

The installation process is fairly easy. First, you need to extract the files from the binary tarball. Then, you need to install the driver's shared library to the appropriate place in your system. The driver's shared library is called libmaodbc.so and it is located in either the lib directory or the lib64 directory, depending on whether you downloaded a 32-bit or 64-bit package. The driver's shared library can be installed anywhere, but for simplicity, the instructions below will assume that you are installing it to /usr/lib64, which is a common directory for 64-bit shared libraries on many Linux distributions.

Installation steps for some common Linux distributions are shown below. The commands would be similar for other Linux distributions. However, the URL of the package and the installation path may be different.

Installing MariaDB Connector/ODBC on RHEL/CentOS

The following commands would download and install MariaDB Connector/ODBC 3.1.7 on RHEL or CentOS 7:

mkdir odbc_package
cd odbc_package
wget https://downloads.mariadb.com/Connectors/odbc/connector-odbc-3.1.7/mariadb-connector-odbc-3.1.7-ga-rhel7-x86_64.tar.gz
tar -xvzf mariadb-connector-odbc-3.1.7-ga-rhel7-x86_64.tar.gz
sudo install lib64/libmaodbc.so /usr/lib64/
sudo install -d /usr/lib64/mariadb/
sudo install -d /usr/lib64/mariadb/plugin/
sudo install lib64/mariadb/plugin/auth_gssapi_client.so /usr/lib64/mariadb/plugin/
sudo install lib64/mariadb/plugin/caching_sha2_password.so /usr/lib64/mariadb/plugin/
sudo install lib64/mariadb/plugin/client_ed25519.so /usr/lib64/mariadb/plugin/
sudo install lib64/mariadb/plugin/dialog.so /usr/lib64/mariadb/plugin/
sudo install lib64/mariadb/plugin/mysql_clear_password.so /usr/lib64/mariadb/plugin/
sudo install lib64/mariadb/plugin/sha256_password.so /usr/lib64/mariadb/plugin/

Installing MariaDB Connector/ODBC on Debian/Ubuntu

The following commands would download and install MariaDB Connector/ODBC 3.1.7 on Debian or Ubuntu:

mkdir odbc_package
cd odbc_package
wget https://downloads.mariadb.com/Connectors/odbc/connector-odbc-3.1.7/mariadb-connector-odbc-3.1.7-ga-debian-x86_64.tar.gz
tar -xvzf mariadb-connector-odbc-3.1.7-ga-debian-x86_64.tar.gz
sudo install lib64/libmaodbc.so /usr/lib/
sudo install -d /usr/lib/mariadb/
sudo install -d /usr/lib/mariadb/plugin/
sudo install lib/mariadb/plugin/auth_gssapi_client.so /usr/lib/mariadb/plugin/
sudo install lib/mariadb/plugin/caching_sha2_password.so /usr/lib/mariadb/plugin/
sudo install lib/mariadb/plugin/client_ed25519.so /usr/lib/mariadb/plugin/
sudo install lib/mariadb/plugin/dialog.so /usr/lib/mariadb/plugin/
sudo install lib/mariadb/plugin/mysql_clear_password.so /usr/lib/mariadb/plugin/
sudo install lib/mariadb/plugin/sha256_password.so /usr/lib/mariadb/plugin/

These steps may not work on the following operating system versions due to the packaging bug ODBC-278:

  • Debian 9 (Stretch)
  • Debian 10 (Buster)
  • Ubuntu 19.10 (Eoan Ermine)
  • Ubuntu 20.04 LTS (Focal Fossa)

Installing MariaDB Connector/ODBC on Mac OS X

To install MariaDB Connector/ODBC on Mac OS X, we distribute PKG packages for releases starting with MariaDB Connector/ODBC 3.1.

MariaDB Connector/ODBC supports the built-in iODBC Driver Manager on Mac OS X, so nothing else needs to be installed.

Installing MariaDB Connector/ODBC from Source

See Building MariaDB Connector/ODBC from Source for information on how to build MariaDB Connector/ODBC from source.

Installing UnixODBC on Linux

In order to use MariaDB Connector/ODBC on Linux, you will also need to install a supported Driver Manager. The only Driver Manager that we currently support on Linux is UnixODBC. In most Linux distributions, you can install UnixODBC by using your Linux distribution's package manager.

For example, the following command would install the unixODBC package on RHEL, CentOS, and similar Linux distributions:

sudo yum install unixODBC

And the following command would install the unixodbc and odbcinst packages on Debian, Ubuntu, and similar Linux distributions:

sudo apt-get update
sudo apt-get install unixodbc odbcinst

If you plan to compile an application from source against MariaDB Connector/ODBC and UnixODBC, then you also need the development header files that define the ODBC API function prototypes, ODBC data types, etc. In most Linux distributions, you can install these UnixODBC development files by using your Linux distribution's package manager.

For example, the following command would install the unixODBC-devel package on on RHEL, CentOS, and similar Linux distributions:

sudo yum install unixODBC-devel

And the following command would install the unixodbc-dev package on on Debian, Ubuntu, and similar Linux distributions:

sudo apt-get update
sudo apt-get install unixodbc-dev

If you can't find the UnixODBC packages with your Linux distribution's package manager, then you may want to look at the download page at UnixODBC.org for other installation options.

Creating a Data Source with MariaDB Connector/ODBC

See Creating a Data Source with MariaDB Connector/ODBC for information on how to create a data source.

Installing Client Authentication Plugins

Authentication plugins are all compiled in statically on Windows since 3.1.18

In MariaDB Connector/ODBC 3.1 and later, MariaDB Connector/ODBC bundles client authentication plugins with the connector.

In MariaDB Connector/ODBC 3.0 and before, MariaDB Connector/ODBC does not bundle client authentication plugins with the connector.

The connector will need to use client authentication plugins in the following scenarios:

  • The server uses the pam authentication plugin.
  • The server uses the gssapi authentication plugin.
  • The server uses the ed25519 authentication plugin.
  • You are connecting to a MySQL server that uses one of the SHA-256 authentication plugins--i.e. either the sha256_password or the caching_sha2_password authentication plugins. However, MariaDB Connector/ODBC is more compatible with MariaDB than with MySQL, and it may not yet fully support these MySQL-only authentication plugins. See ODBC-241 for more information.

If you need client authentication plugins in a version which does not bundle them with the connector, then you will also need to install MariaDB Connector/C, which installs the client authentication plugins as shared libraries, which can be used by MariaDB Connector/ODBC.

MariaDB Connector/ODBC can be configured to use MariaDB Connector/C's client authentication plugins by setting the PLUGINDIR parameter to the MariaDB Connector/C's plugin directory. The plugin directory can also be specified with the MARIADB_PLUGIN_DIR environment variable.

On Windows, MariaDB Connector/C often installs plugins to one of the following directories:

  • C:\Program Files\MariaDB\MariaDB Connector C\lib\plugin
  • C:\Program Files (x86)\MariaDB\MariaDB Connector C\lib\plugin

On Linux, MariaDB Connector/C often installs client authentication plugins to one of the following directories:

  • /usr/lib64/mysql/plugin
  • /usr/lib/mysql/plugin

When you install the client authentication plugins, ensure that they are for the same architecture as your MariaDB Connector/ODBC installation. If your MariaDB Connector/ODBC installation is 64-bit, then you should install 64-bit client authentication plugins. Likewise, if your MariaDB Connector/ODBC installation is 32-bit, then you should install 32-bit client authentication plugins.

Parameters

  • DSN: Name of the DSN
  • Driver: The name of the MariaDB ODBC Driver. On Windows, this must be {MariaDB ODBC 3.1 Driver} for 3.1 drivers, or for versions from other release series, you must use the corresponding version number for that release series. On Linux, either this must be a path to the driver's shared library or it must match the Driver name that you provided when you configured the Driver with UnixODBC.
  • Description: Description of the data source.
  • SaveFile: Save a string representation of the DSN to this file.
  • FileDSN: The file where the string representation of the DSN can be read.
  • Trace: Whether to enable the ODBC trace log.
  • TraceFile: If the ODBC trace log is enabled, then this is the path to the output file.

General Connection Parameters

  • SERVER: name or IP of the MariaDB database server. Aliases: SERVERNAME
  • USER: user name for database authentication. Aliases: UID,
  • PASSWORD: password for database authentication. Aliases: PWD
  • DATABASE: default database. Aliases: DB
  • PORT: TCP/IP Port of the database server
  • OPTION: For MySQL Connector/ODBC compatibility. Aliases: OPTIONS. Here are used bits meaning:
    • 0(1) - Currently is not used
    • 1(2) - Tells connector to return the number of matched rows instead of number of changed rows
    • 4(16) - See NO_PROMPT
    • 5(32) - Forces use of dynamic cursor
    • 6(64) - Forbids the use of database.tablename.column syntax
    • 7(128) Allows [load-data-infile|LOAD DATA INFILE LOCAL]
    • 11(2048) - Tells connector to use compression protocol
    • 13(8192) - See NAMEDPIPE
    • 16(65536) - See USE_MYCNF
    • 21(2097152) - See FORWARDONLY
    • 22(4194304) - See AUTO_RECONNECT
    • 26(67108864) - Allows to send multiple statements in one query
  • NAMEDPIPE: This parameter accepts a boolean value, where all non-zero values are treated as true. When this parameter is enabled, the value of the SOCKET parameter is treated as a named pipe name, rather than a path to a Unix domain socket. Alternatively, setting the 13th bit in the OPTIONS bitmask is equivalent to setting this parameter. This parameter only has an effect on Windows.
  • TCPIP: This parameter has the opposite meaning of the NAMEDPIPE parameter. When TCPIP=0 is set, NAMEDPIPE=1 is effectively set. This parameter only has an effect on Windows.
  • SOCKET: By default, this parameter accepts a path to a Unix domain socket. If NAMEDPIPE=1 is set on Windows, this parameter accepts the name of a named pipe instead. When this parameter is specified, the value of the SERVER parameter and its aliases are ignored.
  • INITSTMT: SQL command(s) to be run at connection time
  • CONN_TIMEOUT : connect timeout in seconds
  • AUTO_RECONNECT: enabling/disabling automatic reconnect, the same as setting/resetting 22th(4194304) OPTIONS bit
  • NO_PROMPT: suppresses prompt dialog display at the connection time. This has the same meaning as setting/resetting bit #4(16) of the OPTIONS
  • CHARSET: connection character set. Connector assumes that all incoming string data is encoded in this character set, and uses it if recoding to/from Unicode(utf16) encoding is required.
  • PLUGIN_DIR: Specify the location of client plugins. Starting from the version 3.1.12, all authentication plugins are compiled in for Windows releases, thus with option becomes Linux/MacOS-specific
  • USE_MYCNF: whether to read options from the [odbc] option group in the system's default my.cnf option file.
  • SERVERKEY: Specifies the name of the file which contains the RSA public key of the database server. The format of this file must be in PEM format. This option is used by the caching_sha2_password client authentication plugin.
    • This parameter is available starting with MariaDB Connector/ODBC version 3.1.4.
  • INTERACTIVE: tells server, that the client is interactive, and it should use interactive_timeout for this connection
    • This parameter is available starting with MariaDB Connector/ODBC version 3.1.10.
  • FORWARDONLY: forces all cursors to be forward only.
    • This parameter is available starting with MariaDB Connector/ODBC version 3.1.10
  • PREPONCLIENT: forces SQLPrepare to use client side prepare if possible.
    • This parameter is available starting with MariaDB Connector/ODBC version 3.2.0
  • ATTR: option to set connection attributes. Using it makes sense only if performance schema is enabled on server. Format: ATTR={<attrname1>=<attrvalue1>[,<attrname2=attrvalue2,...]}
    • This parameter is available starting with MariaDB Connector/ODBC version 3.2.0

General Connection Parameters Example

For example, to set these parameters in a connection string via C/C++ code, you could do something like the following:

SQLWCHAR *ConnStr= L"Driver={MariaDB ODBC 3.2 Driver};SERVER=mydatabase.mydomain.com;USER=odbc_user;PASSWORD=odbc_pw;DATABASE=odbc_test;PORT=3306";

To set these same parameters in a UnixODBC or iODBC configuration file, you could do something like the following:

[MariaDB-server]
Description = MariaDB server
Driver = MariaDB ODBC 3.2 Driver
Trace = Yes
TraceFile = /tmp/trace.log
SERVER = mydatabase.mydomain.com
USER = odbc_user
PASSWORD = odbc_pw
DATABASE = odbc_test
PORT = 3306

The following TLS-related connection parameters are available in MariaDB Connector/ODBC 3.0 and later:

  • SSLCERT: Defines a path to the X509 certificate file to use for TLS. This parameter requires that you use the absolute path, not a relative path.
  • SSLKEY: Defines a path to a private key file to use for TLS. The key file must be unencrypted. This parameter requires that you use the absolute path, not a relative path.
  • SSLCA: Defines a path to a PEM file that should contain one or more X509 certificates for trusted Certificate Authorities (CAs) to use for TLS. This parameter requires that you use the absolute path, not a relative path.
  • SSLCAPATH: Defines a path to a directory that contains one or more PEM files that should each contain one X509 certificate for a trusted Certificate Authority (CA) to use for TLS. This parameter requires that you use the absolute path, not a relative path. The directory specified by this parameter needs to be run through the openssl rehash command.
  • SSLCIPHER: Defines a list of permitted ciphers or cipher suites to use for TLS..
  • SSLVERIFY: Enables (or disables) server certificate verification.
  • SSLCRL: Defines a path to a PEM file that should contain one or more revoked X509 certificates to use for TLS. This parameter requires that you use the absolute path, not a relative path.
  • SSLCRLPATH: Defines a path to a directory that contains one or more PEM files that should each contain one revoked X509 certificate to use for TLS. This parameter requires that you use the absolute path, not a relative path. The directory specified by this parameter needs to be run through the openssl rehash command.
  • TLSVERSION: Specify which TLS versions are allowed. The value can be a comma-separated list of string names consisting of TLSv1.1, TLSv1.2, and TLSv1.3, or it can be an integer value that represents a bitmap, where TLSv1.1 corresponds to bit 1, TLSv1.2 corresponds to bit 2, and TLSv1.3 corresponds to bit 3.
    • This parameter is available starting with MariaDB Connector/ODBC versions 3.0.9 and 3.1.1.
  • FORCETLS: Whether to force TLS.
    • This parameter is available starting with MariaDB Connector/ODBC versions 3.0.9 and 3.1.1.
  • TLSPEERFP: Specify the SHA1 fingerprint of a server certificate for validation during the TLS handshake. Aliases: SSLFP
    • This parameter is available starting with MariaDB Connector/ODBC version 3.1.4.
  • TLSPEERFPLIST: Specify a file which contains one or more SHA1 fingerprints of server certificates for validation during the TLS handshake. Aliases: SSLFPLIST
    • This parameter is available starting with MariaDB Connector/ODBC version 3.1.4.
  • TLSKEYPWD: Specify a passphrase for a passphrase-protected private key, as configured by the SSLKEY option. This option is only supported if the connector was built with OpenSSL or GnuTLS. If the connector was built with Schannel, then this option is not supported.
    • This parameter is available starting with MariaDB Connector/ODBC version 3.1.8.
Two-Way TLS Example

Two-way TLS means that both the client and server provide TLS certificates and keys.

For example, to set these parameters in a connection string via C/C++ code, you could do something like the following:

SQLWCHAR *ConnStr= L"Driver={MariaDB ODBC 3.2 Driver};SERVER=mydatabase.mydomain.com;USER=odbc_user;PASSWORD=odbc_pw;DATABASE=odbc_test;PORT=3306;SSLCERT=/etc/my.cnf.d/certificates/client-cert.pem;SSLKEY=/etc/my.cnf.d/certificates/client-key.pem;SSLCA=/etc/my.cnf.d/certificates/ca.pem;SSLVERIFY=1";

To set these same parameters in a UnixODBC or iODBC configuration file, you could do something like the following:

[MariaDB-server]
Description = MariaDB server
Driver = MariaDB ODBC 3.2 Driver
Trace = Yes
TraceFile = /tmp/trace.log
SERVER = mydatabase.mydomain.com
USER = odbc_user
PASSWORD = odbc_pw
DATABASE = odbc_test
PORT = 3306
SSLCERT = /etc/my.cnf.d/certificates/client-cert.pem
SSLKEY = /etc/my.cnf.d/certificates/client-key.pem
SSLCA = /etc/my.cnf.d/certificates/ca.pem
SSLVERIFY = 1
One-Way TLS Examples
One-Way TLS with Server Certificate Verification Example

One-way TLS means that only the server provides TLS certificates and keys. Server certificate verification means that the client verifies that the certificate belongs to the server.

For example, to set these parameters in a connection string via C/C++ code, you could do something like the following:

SQLWCHAR *ConnStr= L"Driver={MariaDB ODBC 3.2 Driver};SERVER=mydatabase.mydomain.com;USER=odbc_user;PASSWORD=odbc_pw;DATABASE=odbc_test;PORT=3306;SSLCA=/etc/my.cnf.d/certificates/ca.pem;SSLVERIFY=1";

To set these same parameters in a UnixODBC or iODBC configuration file, you could do something like the following:

[MariaDB-server]
Description = MariaDB server
Driver = MariaDB ODBC 3.2 Driver
Trace = Yes
TraceFile = /tmp/trace.log
SERVER = mydatabase.mydomain.com
USER = odbc_user
PASSWORD = odbc_pw
DATABASE = odbc_test
PORT = 3306
SSLCA = /etc/my.cnf.d/certificates/ca.pem
SSLVERIFY = 1
One-Way TLS without Server Certificate Verification Example

One-way TLS means that only the server provides TLS certificates and keys.

For example, to set these parameters in a connection string via C/C++ code, you could do something like the following:

SQLWCHAR *ConnStr= L"Driver={MariaDB ODBC 3.2 Driver};SERVER=mydatabase.mydomain.com;USER=odbc_user;PASSWORD=odbc_pw;DATABASE=odbc_test;PORT=3306;SSLCIPHER=DHE-RSA-AES256-GCM-SHA384";

To set these same parameters in a UnixODBC or iODBC configuration file, you could do something like the following:

[MariaDB-server]
Description = MariaDB server
Driver = MariaDB ODBC 3.2 Driver
Trace = Yes
TraceFile = /tmp/trace.log
SERVER = mydatabase.mydomain.com
USER = odbc_user
PASSWORD = odbc_pw
DATABASE = odbc_test
PORT = 3306
SSLCIPHER = DHE-RSA-AES256-GCM-SHA384

Known Issues

Multiple Statement Execution

Multiple statement execution is not fully supported. This means that if you try to prepare a multi-statement query where one of statements depends on the execution result of one of the previous statements, then it may fail. For example, the following may return an error in some versions:

SQLPrepare(hstmt, "CREATE VIEW some_table_view AS SELECT * FROM some_table;SELECT * FROM some_table_view ", SQL_NTS);

Some bugs related to this have been fixed, such as ODBC-159. If you find similar cases, please report a bug.

3.2 eliminates this issue, but option allowing to send multiple statements in one query(bit 26 = 67108864) has to be selected.

Authenticating with PAM

If you try to authenticate with a user account that is configured to use the pam authentication plugin, then you might see one of the following errors.

You might see this error:

Authentication plugin 'dialog' cannot be loaded: The specified module could not be found.

Or if the server has the pam_use_cleartext_plugin system variable set, then you might see this error instead:

Authentication plugin 'mysql_clear_password' cannot be loaded: The specified module could not be found.

These errors occur because the pam authentication plugin requires specific client authentication plugins in order to work, and MariaDB Connector/ODBC does not install these plugins. To fix the problem, please install the client authentication plugins.

See ODBC-23 for more information.

Authentication plugins are all compiled in statically on Windows since 3.1.18

Reporting Bugs

If you find a bug, please report it via the ODBC project on MariaDB's Jira bug tracker.

Source Code

The source code is available at the mariadb-connector-odbc repository on GitHub.

License

GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version.

For licensing questions, see the Licensing FAQ.

Content reproduced on this site is the property of its respective owners, and this content is not reviewed in advance by MariaDB. The views, information and opinions expressed by this content do not necessarily represent those of MariaDB or any other party.