-
Notifications
You must be signed in to change notification settings - Fork 56
Building MariaDB Connector ODBC
Below versions of MariaDB Connector/ODBC are available in respective distributions at the time of creation of these build instructions:
- RHEL (8.8, 8.10) have
3.1.12-1.el8 - RHEL (9.2, 9.4) have
3.1.12-3.el9 - SLES 15 SP5 has
3.0.2-3.23 - SLES 15 SP6 has
3.0.2-150600.17.2 - Ubuntu (22.04, 24.04) have
3.1.15-3
The instructions provided below specify the steps to build MariaDB Connector/ODBC version 3.2.2 on Linux on IBM Z for following distributions:
- RHEL (8.8, 8.10, 9.2, 9.4)
- SLES (12 SP5, 15 SP5, 15 SP6)
- Ubuntu (20.04, 22.04, 24.04)
General Notes:
-
When following the steps below, please use a standard permission user unless otherwise specified.
-
A directory
/<source_root>/will be referred to in these instructions, this is a temporary writable directory anywhere you'd like to place it.
If you want to build MariaDB Connector/ODBC using manual steps, go to Step 2.
Use the following commands to build MariaDB Connector ODBC using the build script. Please make sure you have wget installed.
wget -q https://raw.githubusercontent.com/linux-on-ibm-z/scripts/master/MariaDB-Connector-ODBC/3.2.2/build_mariadb_connector_odbc.sh
# Build MariaDB Connector/ODBC
bash build_mariadb_connector_odbc.sh [Provide -t option for executing build with tests]In case of error, check logs for more details or go to STEP 2 to follow manual build steps.
MariaDB ODBC connector requires minimum MariaDB version 10.2.7. Instructions to build MariaDB server are provided here
Note: At the time of creation of these build instructions, MariaDB Connector/ODBC was verified with MariaDB 10.10.2
export SOURCE_ROOT=/<source_root>/
-
RHEL (9.2, 9.4)
sudo yum install -y mariadb mariadb-server unixODBC unixODBC-devel git cmake gcc gcc-c++ libarchive openssl-devel openssl tar curl libcurl-devel krb5-devel make glibc-langpack-en -
RHEL (8.8, 8.10)
sudo yum install -y mariadb mariadb-server unixODBC unixODBC-devel git cmake gcc gcc-c++ libarchive openssl-devel openssl tar curl libcurl-devel krb5-devel make glibc-langpack-en -
SLES 15 SP5
sudo zypper install -y git cmake gcc gcc-c++ mariadb libopenssl-devel openssl glibc-locale tar curl libcurl-devel krb5-devel autoconf automake libtool -
SLES 15 SP6
sudo zypper install -y git cmake gcc gcc-c++ mariadb libopenssl-devel openssl glibc-locale tar curl libcurl-devel krb5-devel autoconf automake libtool awk -
SLES 12 SP5
sudo zypper install -y mariadb unixODBC-devel-2.3.6-7.9.1 git cmake gcc gcc-c++ libopenssl-devel openssl glibc-locale tar curl libcurl-devel krb5-devel -
Ubuntu (20.04, 22.04, 24.04)
sudo apt-get update sudo apt-get install -y mariadb-server unixodbc-dev odbcinst git cmake gcc g++ libssl-dev tar curl libcurl4-openssl-dev libkrb5-dev
- Download unixODBC source code
cd $SOURCE_ROOT git clone https://github.com/lurcher/unixODBC.git cd unixODBC git checkout v2.3.9 curl -o iconv.diff https://raw.githubusercontent.com/linux-on-ibm-z/scripts/master/MariaDB-Connector-ODBC/3.2.2/patch/iconv.diff git apply --ignore-whitespace iconv.diff autoreconf -fi ./configure make sudo make install
-
Download MariaDB Connector/ODBC source code
cd $SOURCE_ROOT git clone -b 3.2.2 https://github.com/MariaDB/mariadb-connector-odbc.git cd mariadb-connector-odbc git submodule init git submodule update
-
Build and install
-
For RHEL and SLES 12
cmake -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=RelWithDebInfo -DCONC_WITH_UNIT_TESTS=Off -DWITH_SSL=OPENSSL -DCMAKE_INSTALL_PREFIX=/usr/local make sudo make install sudo cp /usr/local/lib/mariadb/libmaodbc.so /usr/local/lib -
For SLES 15.x
cmake -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=RelWithDebInfo -DCONC_WITH_UNIT_TESTS=Off -DWITH_SSL=OPENSSL -DCMAKE_INSTALL_PREFIX=/usr/local -DODBC_LIB_DIR=/usr/local/lib make sudo make install sudo cp /usr/local/lib/mariadb/libmaodbc.so /usr/local/lib -
For Ubuntu
cmake -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=RelWithDebInfo -DCONC_WITH_UNIT_TESTS=Off -DWITH_SSL=OPENSSL -DCMAKE_INSTALL_PREFIX=/usr/local -DODBC_LIB_DIR=/usr/lib/s390x-linux-gnu/ make sudo make install sudo cp /usr/local/lib/mariadb/libmaodbc.so /usr/local/lib
-
-
Start MariaDB server
sudo mysql_install_db --user=mysql sudo mysqld_safe --user=mysql & -
Create the following softlink
- RHEL
sudo ln -s /var/lib/mysql/mysql.sock /tmp/mysql.sock
- SLES
sudo ln -s /run/mysql/mysql.sock /tmp/mysql.sock
- Ubuntu
sudo ln -s /var/run/mysqld/mysqld.sock /tmp/mysql.sock
- RHEL
-
Update root plugin and create test database (Ubuntu Only)
- Ubuntu 20.04
sudo mysql -u root -e "USE mysql; UPDATE user SET plugin='mysql_native_password' WHERE User='root'; FLUSH PRIVILEGES;" sudo env PATH=$PATH mysql -u root -e "CREATE DATABASE IF NOT EXISTS test;"
- Ubuntu (22.04, 24.04)
sudo env PATH=$PATH mysql -u root -e "ALTER USER 'root'@'localhost' IDENTIFIED VIA mysql_native_password USING PASSWORD('');" sudo env PATH=$PATH mysql -u root -e 'CREATE DATABASE IF NOT EXISTS test;'
- Ubuntu 20.04
-
Set password for root@localhost
- For Ubuntu and SLES 15.x
sudo env PATH=$PATH mysql -u root -e "SET PASSWORD FOR 'root'@'localhost' = PASSWORD('');"
- For all other distros
sudo env PATH=$PATH mysql -u root -e "SET PASSWORD FOR 'root'@'localhost' = PASSWORD('rootpass');"
- For Ubuntu and SLES 15.x
-
Set the environment variables
export TEST_DRIVER=maodbc_test export TEST_SCHEMA=test export TEST_DSN=maodbc_test export TEST_UID=root
- For Ubuntu and SLES 15.x
export TEST_PASSWORD= - For all other distros
export TEST_PASSWORD=rootpass
- For Ubuntu and SLES 15.x
-
Edit
odbc.inifile and append the following text (Don't edit for Ubuntu)Note: Edit
/etc/odbc.inion RHEL and/etc/unixODBC/odbc.inion SLES 12.[maodbc_test] Driver = maodbc_test DESCRIPTION = MariaDB ODBC Connector Test SERVER = localhost PORT = 3306 DATABASE = test UID = root PASSWORD = rootpass -
Edit
odbcinst.inifile and append the following text (Don't edit for Ubuntu)Note:Edit
/etc/odbcinst.inion RHEL,/etc/unixODBC/odbcinst.inion SLES 12.- For RHEL and SLES
[ODBC] # Change to "yes" to turn on tracing Trace = no TraceFile = /tmp/maodbc_trace.log [maodbc_test] Driver = /usr/local/lib/libmaodbc.so DESCRIPTION = MariaDB ODBC Connector Threading = 0 IconvEncoding=UTF16
- For RHEL and SLES
-
Run tests
cd $SOURCE_ROOT/mariadb-connector-odbc/test
- Set the environment variables (Only for Ubuntu and SLES 15.x)
export ODBCINI="$PWD/odbc.ini" export ODBCSYSINI=$PWD
- Run command for test cases
ctest
- Set the environment variables (Only for Ubuntu and SLES 15.x)
Note
-
odbc_connstringis expected to fail for RHEL and SLES. This test case fails on Intel as well as IBM Z and issue is known. -
odbc_preparemay fail based on thesecure-file-privoption in your MariaDB configuration.
The information provided in this article is accurate at the time of writing, but on-going development in the open-source projects involved may make the information incorrect or obsolete. Please open issue or contact us on IBM Z Community if you have any questions or feedback.