MariaDB Connector/ODBC

Overview

ODBC developers can connect to MariaDB SkySQL from their application using MariaDB Connector/ODBC.

Compatibility

MariaDB Connector/ODBC can be used with:

  • MariaDB Platform for Transactions

  • MariaDB Platform for Analytics

  • MariaDB Platform for Smart Transactions (HTAP)

  • MariaDB Platform for Distributed SQL

Connector

MariaDB Connector/ODBC

Supported Versions

3.1

Programming Language

C

API

ODBC 3.5

Supports TLS

Yes

License

GNU Lesser General Public License v2.1

MariaDB Connector/ODBC installation and connection instructions follow. Additional information on MariaDB Connector/ODBC can be found in the Connector/ODBC reference.

Installing MariaDB Connector/ODBC

The method for installing MariaDB Client varies by operating system.

Installing MariaDB Connector/ODBC via Binary Tarball (Linux)

  1. Go to the MariaDB Connector/ODBC download page.

  2. In the "OS" drop-down, select your distribution of Linux.

  3. Click on the "Download" button to download the file.

  4. Extract the tarball:

    $ tar -xvzf mariadb-connector-odbc-*.tar.gz
    
  5. Change directory:

    $ cd mariadb-connector-odbc-*
    
  6. Install the library:

    • On RHEL/CentOS:

      $ sudo install lib64/mariadb/libmaodbc.so /usr/lib64/
      $ sudo install -d /usr/lib64/mariadb/
      $ sudo install -d /usr/lib64/mariadb/plugin/
      $ sudo install lib64/mariadb/plugin/* /usr/lib64/mariadb/plugin/
      
    • On Debian/Ubuntu:

      $ sudo install lib64/mariadb/libmaodbc.so /usr/lib/
      $ sudo install -d /usr/lib/mariadb/
      $ sudo install -d /usr/lib/mariadb/plugin/
      $ sudo install lib64/mariadb/plugin/* /usr/lib/mariadb/plugin/
      

Installing MariaDB Connector/ODBC via MSI (Windows)

  1. Go to the MariaDB Connector/ODBC download page.

  2. In the "OS" drop-down, select either "MS Windows 64-bit" or "MS Windows 32-bit", depending on whether you need a 64-bit or a 32-bit library..

  3. Click on the "Download" button to download the MSI package.

  4. When the MSI package finishes downloading, run it.

  5. On the first screen, click "Next" to start the Setup Wizard.

  6. On the second screen, click the license agreement checkbox, and then click "Next".

  7. On the third screen, click "Typical".

  8. On the next screen, click "Install".

  9. When the installation process completes, click "Finish".

Installing MariaDB Connector/ODBC via PKG (macOS)

  1. Go to the MariaDB Connector/ODBC download page.

  2. In the "OS" drop-down, select "macOS."

  3. Click the "Download" button to download the PKG package.

  4. Run the PKG package to install.

Driver Managers

MariaDB Connector/ODBC requires a driver manager to provide the application interface for ODBC connections. The specific driver manager varies by operating system.

Installing unixODBC on Linux via YUM (CentOS/RHEL)

Install unixODBC using YUM:

$ sudo yum install unixODBC

Installing unixODBC on Linux via APT (Debian/Ubuntu)

Install unixODBC using APT:

$ sudo apt update
$ sudo apt install unixodbc

Installing unixODBC on Linux via ZYpp (SLES)

Install unixODBC using ZYpp:

$ sudo zypper install unixODBC

Installing iODBC on macOS via PKG

  1. Go to iODBC.org:

    http://www.iodbc.org/dataspace/doc/iodbc/wiki/iodbcWiki/Downloads

  2. Download the disk image for iODBC.

  3. Install the disk image.

Connecting with MariaDB Connector/ODBC

MariaDB Connector/ODBC procedures vary by operating system.

Connecting with MariaDB Connector/ODBC on Linux

  1. Create a unixODBC driver template file named MariaDB_odbc_driver_template.ini:

    On RHEL/CentOS:

    [MariaDB ODBC 3.1 Driver]
    Description = MariaDB Connector/ODBC v.3.1
    Driver = /usr/lib64/libmaodbc.so
    

    On Debian/Ubuntu:

    [MariaDB ODBC 3.1 Driver]
    Description = MariaDB Connector/ODBC v.3.1
    Driver = /usr/lib/libmaodbc.so
    
  2. Install the unixODBC driver template file:

    $ sudo odbcinst -i -d -f MariaDB_odbc_driver_template.ini
    
  3. Determine the connection information for your MariaDB SkySQL database service:

    What

    Where to find it

    SERVER

    Fully Qualified Domain Name in the Service Details view

    PORT

    Read-Write Port or Read-Only Port in the Service Details view

    USER

    Default username in the Service Credentials view, or the username you created

    PASSWORD

    Default password in the Service Credentials view, the password you set on the default user, or the password for the user you created

    SSLCA

    Path to the skysql_chain.pem file containing the "Certificate Authority Chain" (Download)

    FORCETLS

    Set to 1 to enable TLS

  4. Configure a unixODBC data source template file named MariaDB_SkySQL_odbc_data_source_template.ini:

    # Data Source for unixODBC
    # intended for MariaDB SkySQL
    [MariaDB-SkySQL-Service]
    Description = MariaDB SkySQL Service
    Driver = MariaDB ODBC 3.1 Driver
    Trace = Yes
    TraceFile = /tmp/trace.log
    SERVER=example.skysql.net
    PORT=5001
    USER=db_user
    PASSWORD=db_user_passwd
    SSLCA=/path/to/skysql_chain.pem
    FORCETLS=1
    
    • Replace "MariaDB-SkySQL-Service" with a name for your data source.

    • Substitute the values of the SERVER, PORT, USER, PASSWORD, and SSLCA parameters with the relevant value for your environment.

  5. Install the unixODBC data source template file:

    $ odbcinst -i -s -h -f MariaDB_SkySQL_odbc_data_source_template.ini
    
  6. Test the data source using the isql command:

    $ isql MariaDB-SkySQL-Service
    +-------------------------+
    | Connected!              |
    | sql-statement           |
    | help[tablename]         |
    | quit                    |
    +-------------------------+
    SQL>
    
  7. To select your new data source in your application, select the data source with the name you configured. In the example it is MariaDB-SkySQL-Service.

Connecting with MariaDB Connector/ODBC on macOS

  1. Confirm that MariaDB Connector/ODBC has been registered with iODBC by confirming that the following options are set in the iODBC configuration file at /Library/ODBC/odbcinst.ini:

    [ODBC]
    Trace     = no
    TraceFile = /tmp/iodbc_trace.log
    
    [ODBC Drivers]
    MariaDB ODBC 3.1 Unicode Driver = Installed
    
    [MariaDB ODBC 3.1 Unicode Driver]
    Driver      = /Library/MariaDB/MariaDB-Connector-ODBC/libmaodbc.dylib
    Description = MariaDB Connector/ODBC(Unicode) 3.1 64bit
    Threading   = 0
    
  2. Determine the connection information for your MariaDB SkySQL database service:

    What

    Where to find it

    SERVER

    Fully Qualified Domain Name in the Service Details view

    PORT

    Read-Write Port or Read-Only Port in the Service Details view

    USER

    Default username in the Service Credentials view, or the username you created

    PASSWORD

    Default password in the Service Credentials view, the password you set on the default user, or the password for the user you created

    SSLCA

    Path to the skysql_chain.pem file containing the "Certificate Authority Chain" (Download)

    FORCETLS

    Set to 1 to enable TLS

  3. Add a data source to iODBC for your database service by adding the following options to the iODBC configuration file at /Library/ODBC/odbc.ini:

    [ODBC Data Sources]
    MariaDB-SkySQL-Service = MariaDB ODBC 3.1 Unicode Driver
    
    [MariaDB-SkySQL-Service]
    Driver=/Library/MariaDB/MariaDB-Connector-ODBC/libmaodbc.dylib
    SERVER=example.skysql.net
    PORT=5001
    USER=db_user
    PASSWORD=db_user_passwd
    SSLCA=/path/to/skysql_chain.pem
    FORCETLS=1
    
    • Replace "MariaDB-SkySQL-Service" with a name for your data source.

    • Substitute the values of the SERVER, PORT, USER, PASSWORD, and SSLCA parameters with the relevant value for your environment.

  4. Test the data source using the iodbctest command:

    $ iodbctest "DSN=MariaDB-SkySQL-Service"
    
  5. To select your new data source in your application, select the data source with the name you configured. In the example, it is MariaDB-SkySQL-Service.

Connecting with MariaDB Connector/ODBC on Windows

Note

Windows 10 was used to prepare these instructions. When using other versions of Windows, these instructions may require adjustment.

  1. Determine the connection information for your MariaDB SkySQL database service:

    What

    Where to find it

    SERVER

    Fully Qualified Domain Name in the Service Details view

    PORT

    Read-Write Port or Read-Only Port in the Service Details view

    USER

    Default username in the Service Credentials view, or the username you created

    PASSWORD

    Default password in the Service Credentials view, the password you set on the default user, or the password for the user you created

    SSLCA

    Path to the skysql_chain.pem file containing the "Certificate Authority Chain" (Download)

    FORCETLS

    Set to 1 to enable TLS

  2. In the start menu, search for "ODBC Data Sources".

  3. In the search results, open up the application called "ODBC Data Sources (32-bit)" or "ODBC Data Sources (64-bit)", depending on whether you need a data source for a 32-bit or 64-bit application.

  4. In the ODBC Data Source Administrator, click the "Add" button on the right side.

  5. In the "Create New Data Source" window:

    • Click on "MariaDB ODBC 3.1 Driver" in the list.

    • Click the "Finish" button.

  6. In the "Create a new Data Source to MariaDB" window:

    • In the "Name" text box, enter a name for the data source.

    • In the "Description" test box, enter a description for the data source.

    • Click the "Next" button.

  7. In the next window:

    • In the "Server Name" text box, enter the Fully Qualified Domain Name from the Service Details view.

    • In the "Port" text box, enter the read-write port or read-only port from the Service Details view.

    • In the "User name" text box, enter the default username in the Service Credentials view, or the username you created.

    • In the "Password" text box, enter the default password in the Service Credentials view, the password you set on the default user, or the password for the user you created.

    • In the "Database" text box, enter the database name that you would like to connect to.

    • Click the "Next" button.

  8. In the next window:

    • Fill in any optional parameters.

    • Click the "Next" button.

  9. In the next window:

    • Fill in any optional parameters.

    • Click the "Next" button.

  10. In the next window:

    • In the "Certificate Authority" text box, enter the path to the skysql_chain.pem file containing the "Certificate Authority Chain" (Download)

    • Select the "Verify Certificate" checkbox.

    • Select the "Force TLS Use" checkbox.

    • Click the "Next" button.

  11. In the next window:

    • Fill in any optional parameters.

    • Click the "Finish" button.

  12. To select your new data source in your application, select the data source with the name that you configured for the "Name" field.