Building MariaDB Connector ODBC - linux-on-ibm-z/docs GitHub Wiki
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 have
3.1.12-1.el8
- RHEL 9.2 have
3.1.12-3.el9
- SLES 15 SP5 has
3.0.2-3.23
- Ubuntu 22.04 have
3.1.15-3
The instructions provided below specify the steps to build MariaDB Connector/ODBC version 3.1.20 on Linux on IBM Z for following distributions:
- RHEL (8.8, 9.2)
- SLES (12 SP5, 15 SP5)
- Ubuntu (20.04, 22.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.
Build and Install MariaDB Connector/ODBC
Step 1: Build using script
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.1.20/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.
Step 2: Install dependencies
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
sudo subscription-manager repos --enable=codeready-builder-for-rhel-9-s390x-rpms sudo yum install -y mariadb mariadb-server unixODBC unixODBC-devel git cmake gcc libarchive openssl-devel openssl tar curl libcurl-devel krb5-devel make glibc-langpack-en
-
RHEL 8.8
sudo yum install -y mariadb mariadb-server unixODBC unixODBC-devel git cmake gcc libarchive openssl-devel openssl tar curl libcurl-devel krb5-devel make glibc-langpack-en
-
SLES 15 SP5
sudo zypper install -y git cmake gcc mariadb libopenssl-devel openssl glibc-locale tar curl libcurl-devel krb5-devel autoconf automake libtool
-
SLES 12 SP5
sudo zypper install -y mariadb unixODBC-devel-2.3.6-7.9.1 git cmake gcc libopenssl-devel openssl glibc-locale tar curl libcurl-devel krb5-devel
-
Ubuntu (20.04, 22.04)
sudo apt-get update sudo apt-get install -y mariadb-server unixodbc-dev odbcinst git cmake gcc libssl-dev tar curl libcurl4-openssl-dev libkrb5-dev
Step 3: Build and install unixODBC (SLES 15.x)
- 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.1.20/patch/iconv.diff git apply --ignore-whitespace iconv.diff autoreconf -fi ./configure make sudo make install
Step 4: Build and install MariaDB Connector/ODBC
-
Download MariaDB Connector/ODBC source code
cd $SOURCE_ROOT git clone -b 3.1.20 https://github.com/MariaDB/mariadb-connector-odbc.git cd mariadb-connector-odbc git submodule init git submodule update curl -o odbc.diff https://raw.githubusercontent.com/linux-on-ibm-z/scripts/master/MariaDB-Connector-ODBC/3.1.20/patch/odbc.diff git apply --ignore-whitespace odbc.diff
-
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
-
Step 5: Testing (Optional)
5.1) Start MariaDB server and configure for testing
-
Start MariaDB server
- RHEL (8.x, 9.x), SLES, Ubuntu (20.04, 22.04)
sudo mysql_install_db --user=mysql sudo mysqld_safe --user=mysql &
- RHEL (8.x, 9.x), SLES, Ubuntu (20.04, 22.04)
-
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
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
5.2) Run Connector/ODBC test cases
-
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.ini
file and append the following text (Don't edit for Ubuntu)Note: Edit
/etc/odbc.ini
on RHEL and/etc/unixODBC/odbc.ini
on SLES 12.[maodbc_test] Driver = maodbc_test DESCRIPTION = MariaDB ODBC Connector Test SERVER = localhost PORT = 3306 DATABASE = test UID = root PASSWORD = rootpass
-
Edit
odbcinst.ini
file and append the following text (Don't edit for Ubuntu)Note:Edit
/etc/odbcinst.ini
on RHEL,/etc/unixODBC/odbcinst.ini
on 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_connstring
is expected to fail for RHEL and SLES. This test case fails on Intel as well as IBM Z and issue is known.odbc_prepare
may fail based on thesecure-file-priv
option in your MariaDB configuration.