Instalasi dan Konfigurasi MariaDB unixODBC Driver - Rumah IT

Baru

recent

Instalasi dan Konfigurasi MariaDB unixODBC Driver

Instalasi dan Konfigurasi MariaDB unixODBC Driver

Driver MariaDB unixODBC tidak tersedia di repositori paket Debian saat ini, tetapi kita dapat membuat dan mengonfigurasinya sendiri. Cara ini membutuhkan beberapa pekerjaan tambahan, sampai benar-benar bisa digunakan. Mari kita ikuti bersama panduan ini.


1. Instal MariaDB Server

Langkah ini opsional, tetapi akan berguna selama fase pengujian.

$ sudo apt-get install mariadb-server

Saya akan menggunakan versi server database berikut.
$ apt-cache policy mariadb-server
mariadb-server:
  Installed: 10.1.26-0+deb9u1
  Candidate: 10.1.26-0+deb9u1
  Version table:
 *** 10.1.26-0+deb9u1 500
        500 http://ftp.task.gda.pl/debian stretch/main amd64 Packages
        500 http://security.debian.org/debian-security stretch/updates/main amd64 Packages
        100 /var/lib/dpkg/status
Buat contoh database untuk menguji apakah driver unixODBC berfungsi seperti yang diharapkan.
$ cat << EOF | sudo mariadb
CREATE USER 'milosz'@'localhost' IDENTIFIED BY 'password';
CREATE DATABASE localdb;
GRANT ALL ON localdb.* TO 'milosz'@'localhost';
USE localdb;
CREATE TABLE IF NOT EXISTS sample_table (varchar_column varchar(50) DEFAULT NULL);
INSERT INTO sample_table (varchar_column) VALUES ('test value');
EOF

2. Instal unixODBC

Instal perangkat lunak unixODBC .

$ sudo apt-get install unixodbc unixodbc-dev odbcinst

3. Instal Essential Utilities

Instal dependensi yang diperlukan.

$ sudo apt-get install git checkinstall cmake build-essential libssl1.0-dev

4. Build MariaDB client library

Paket ini diperlukan untuk membangun driver unixODBC. Paket ini tumpang tindih dengan libmariadb-dev , tetapi memberikan file header tambahan yang hilang dalam paket Debian yang disebutkan.
Klon MariaDB client library

$ git clone https://github.com/MariaDB/mariadb-connector-c.git

Selanjutnya kita ubah direktori kerja .

$ cd mariadb-konektor-c

Menampilkan tag yang tersedia.

tag $git
v2.2.1
v2.2.2
v2.2.3
v2.3.0
v2.3.1
v2.3.2
v2.3.3_pra
v3.0-cc-server-integ-0
v3.0.1-beta
v3.0.2
v_2.3.3
v_2.3.4

Periksa tag v3.0.2.

$ git checkout tag/v3.0.2

Generate standard UNIX makefiles
$ cmake -G "Unix Makefiles" -DCMAKE_INSTALL_PREFIX=/usr/local -LH
-- Could NOT find CURL (missing:  CURL_LIBRARY CURL_INCLUDE_DIR) 
-- Could NOT find CURL (missing:  CURL_LIBRARY CURL_INCLUDE_DIR) 
SYSTEM processor: x86_64
-- Configuring done
-- Generating done
-- Build files have been written to: /home/milosz/mariadb-connector-c
-- Cache values
// Choose the type of build, options are: None(CMAKE_CXX_FLAGS or CMAKE_C_FLAGS used) Debug Release RelWithDebInfo MinSizeRel.
CMAKE_BUILD_TYPE_STRING=

// Install path prefix, prepended onto install directories.
CMAKE_INSTALL_PREFIX_PATH=/usr/local

// Installation layout. Currently supported options are DEFAULT (tar.gz and zip) and RPM
INSTALL_LAYOUT_STRING=DEFAULT

// Enables use of curl
WITH_CURL_BOOL=ON

// Enables support of dynamic columns
WITH_DYNCOL_BOOL=ON

// Enables use of external zlib
WITH_EXTERNAL_ZLIB_BOOL=OFF

// creates libmysql* symbolic links
WITH_MYSQLCOMPAT_BOOL=OFF

// Enables use of TLS/SSL library
WITH_SSL_BOOL=ON
Kemudian kita compile source codenya :

$ make

Buat deskripsi paket

$ echo "MariaDB ODBC client library" | tee description-pak

Build paket

$ checkinstall --nodoc --pkgname "mariadb-connector-client-library" --pkgversion "3.0.2" --provides "mariadb-connector-client-library" --requires "libssl1.0.2" --requires "mariadb-server" --maintainer "milosz@localhost" --replaces none --conflicts none --install=no -y

checkinstall 1.6.2, Copyright 2009 Felipe Eduardo Sanchez Diaz Duran
           This software is released under the GNU GPL.



*****************************************
**** Debian package creation selected ***
*****************************************

This package will be built according to these values: 

0 -  Maintainer: [ milosz@localhost ]
1 -  Summary: [ MariaDB ODBC client library ]
2 -  Name:    [ mariadb-connector-client-library ]
3 -  Version: [ 3.0.2 ]
4 -  Release: [ 1 ]
5 -  License: [ GPL ]
6 -  Group:   [ checkinstall ]
7 -  Architecture: [ amd64 ]
8 -  Source location: [ mariadb-connector-c ]
9 -  Alternate source location: [  ]
10 - Requires: [ mariadb-server ]
11 - Provides: [ mariadb-connector-client-library ]
12 - Conflicts: [ none ]
13 - Replaces: [ none ]

Enter a number to change any of them or press ENTER to continue: 

Installing with make install...

========================= Installation results ===========================
[ 44%] Built target mariadb_obj
[ 45%] Built target mariadbclient
[ 46%] Built target libmariadb
[ 49%] Built target dialog
[ 51%] Built target mysql_clear_password
[ 53%] Built target mariadb_config
[ 55%] Built target cctap
[ 57%] Built target ma_getopt
[ 59%] Built target view
[ 61%] Built target sqlite3
[ 63%] Built target errors
[ 65%] Built target cursor
[ 67%] Built target performance
[ 69%] Built target charset
[ 71%] Built target t_aurora
[ 73%] Built target thread
[ 74%] Built target async
[ 76%] Built target fetch
[ 78%] Built target connection
[ 80%] Built target t_conc173
[ 82%] Built target basic-t
[ 84%] Built target logs
[ 86%] Built target bulk1
[ 88%] Built target ps
[ 89%] Built target ps_bugs
[ 91%] Built target result
[ 93%] Built target sp
[ 95%] Built target misc
[ 97%] Built target ps_new
[ 99%] Built target features-10_2
[100%] Built target dyncol
Install the project...
-- Install configuration: "RelWithDebInfo"
-- Installing: /usr/local/include/mariadb/mariadb_com.h
-- Installing: /usr/local/include/mariadb/mysql.h
-- Installing: /usr/local/include/mariadb/mariadb_stmt.h
-- Installing: /usr/local/include/mariadb/ma_pvio.h
-- Installing: /usr/local/include/mariadb/ma_tls.h
-- Installing: /usr/local/include/mariadb/mariadb_version.h
-- Installing: /usr/local/include/mariadb/ma_list.h
-- Installing: /usr/local/include/mariadb/errmsg.h
-- Installing: /usr/local/include/mariadb/mariadb_dyncol.h
-- Installing: /usr/local/include/mariadb/mariadb_ctype.h
-- Installing: /usr/local/include/mariadb/mysqld_error.h
-- Installing: /usr/local/include/mariadb/mysql/client_plugin.h
-- Installing: /usr/local/include/mariadb/mysql/plugin_auth_common.h
-- Installing: /usr/local/include/mariadb/mysql/plugin_auth.h
-- Installing: /usr/local/include/mariadb/mariadb/ma_io.h
-- Installing: /usr/local/lib/mariadb/libmariadbclient.a
-- Installing: /usr/local/lib/mariadb/libmariadb.so.3
-- Installing: /usr/local/lib/mariadb/libmariadb.so
-- Installing: /usr/local/lib/mariadb/plugin/dialog.so
-- Installing: /usr/local/lib/mariadb/plugin/mysql_clear_password.so
-- Installing: /usr/local/bin/mariadb_config

======================== Installation successful ==========================

Some of the files created by the installation are inside the home directory: /home

You probably don't want them to be included in the package.
Do you want me to list them?  [n]: n
Should I exclude them from the package? (Saying yes is a good idea)  [n]: n

Copying files to the temporary directory...OK

Stripping ELF binaries and libraries...OK

Compressing man pages...OK

Building file list...OK

Building Debian package...OK

NOTE: The package will not be installed

Erasing temporary files...OK

Writing backup package...OK
OK

Deleting temp dir...OK


**********************************************************************

 Done. The new package has been saved to

 /home/milosz/mariadb-connector-c/mariadb-connector-client-library_3.0.2-1_amd64.deb
 You can install it in your system anytime using: 

      dpkg -i mariadb-connector-client-library_3.0.2-1_amd64.deb

**********************************************************************

Instal paket yang dibuat.

$ sudo dpkg -i mariadb-connector-client-library_3.0.2-1_amd64.deb

Mengubah direktori kerja 

$ cd

5. Membangun driver unixODBC MariaDB

Klon MariaDB Connector ODBC
$ git clone https://github.com/MariaDB/mariadb-connector-odbc.git
Cloning into 'mariadb-connector-odbc'...
remote: Counting objects: 2376, done.
remote: Compressing objects: 100% (15/15), done.
remote: Total 2376 (delta 9), reused 9 (delta 5), pack-reused 2356
Receiving objects: 100% (2376/2376), 2.87 MiB | 581.00 KiB/s, done.
Resolving deltas: 100% (1905/1905), done.
Ubah direktori kerja

$ cd mariadb-connector-odbc

Menampilkan tag yang tersedia.

$ git tag
1.0.3
1.0.5
1.0.6
2.0.0
2.0.10
2.0.11
2.0.12
2.0.13
2.0.14
2.0.15
2.0.9
3.0.0
3.0.1
3.0.2

Periksa tag 3.0.1. Anda tidak dapat menggunakan versi 3.0.2, pustaka klien yang digunakan tidak mendeklarasikan STMT_INDICATOR_IGNORE_ROW (4)tag di dalam enum_indicator_typejenis yang disebutkan.

$ git checkout tags/3.0.1

Generate standard UNIX makefiles.
$ cmake -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=Release -DWITH_OPENSSL=true -DCMAKE_INSTALL_PREFIX=/usr/local -LH
-- Found MariaDB libraries: /usr/local/lib/mariadb/
-- Found ODBC Driver Manager includes: /usr/include
-- Found ODBC Driver Manager libraries: /usr/lib/x86_64-linux-gnu
-- Checking if SQLColAttribute expects SQLPOINTER FALSE
-- Configuring to build with OpenSSL
-- Configuring tests for linking against the DM library
-- Configuring Test Driver: maodbc_test, Test DSN: maodbc_test, tcp://root@localhost:3306/test socket: 
-- linux
-- License File: /home/milosz/mariadb-connector-c/mariadb-connector-odbc/COPYING
-- ReadMe File: /home/milosz/mariadb-connector-c/mariadb-connector-odbc/README
-- Source Package Filename: mariadb-connector-odbc-3.0.1-beta-src.TGZ
-- Configuring done
-- Generating done
-- Build files have been written to: /home/milosz/mariadb-connector-c/mariadb-connector-odbc
-- Cache values
// Choose the type of build, options are: None(CMAKE_CXX_FLAGS or CMAKE_C_FLAGS used) Debug Release RelWithDebInfo MinSizeRel.
CMAKE_BUILD_TYPE_STRING=Release

// Install path prefix, prepended onto install directories.
CMAKE_INSTALL_PREFIX_PATH=/usr/local

// Path to a file.
MARIADB_BIN_DIR_PATH=/usr/local/bin

// Path to a file.
MARIADB_INCLUDE_DIR_PATH=MARIADB_INCLUDE_DIR-NOTFOUND

// Path to a program.
ODBC_CONFIG_FILEPATH=ODBC_CONFIG-NOTFOUND

// Driver Manager Includes
ODBC_INCLUDE_DIR_PATH=/usr/include

// Driver Manager Libraries
ODBC_LIB_DIR_PATH=/usr/lib/x86_64-linux-gnu

Kemudian compile source code 

$ make

Buat deskripsi paket.

$ echo "MariaDB ODBC driver" | tee description-pak

Build paket
$ checkinstall --nodoc --pkgname "mariadb-connector-odbc" --pkgversion "3.0.1" --provides "mariadb-connector-odbc" --requires "unixodbc,odbcinst,libssl1.0.2" --maintainer "milosz@localhost" --replaces none --conflicts none --install=no -y
checkinstall 1.6.2, Copyright 2009 Felipe Eduardo Sanchez Diaz Duran
           This software is released under the GNU GPL.



*****************************************
**** Debian package creation selected ***
*****************************************

This package will be built according to these values: 

0 -  Maintainer: [ milosz@localhost ]
1 -  Summary: [ MariaDB ODBC driver ]
2 -  Name:    [ mariadb-connector-odbc ]
3 -  Version: [ 3.0.1 ]
4 -  Release: [ 1 ]
5 -  License: [ GPL ]
6 -  Group:   [ checkinstall ]
7 -  Architecture: [ amd64 ]
8 -  Source location: [ mariadb-connector-odbc ]
9 -  Alternate source location: [  ]
10 - Requires: [ unixodbc,odbcinst,libssl1.0.2 ]
11 - Provides: [ mariadb-connector-odbc ]
12 - Conflicts: [ none ]
13 - Replaces: [ none ]

Enter a number to change any of them or press ENTER to continue: 

Installing with make install...

========================= Installation results ===========================
[ 29%] Built target maodbc
[ 33%] Built target connstring
[ 36%] Built target multistatement
[ 38%] Built target result2
[ 41%] Built target catalog2
[ 44%] Built target tran
[ 47%] Built target scroll
[ 50%] Built target use_result
[ 52%] Built target param
[ 55%] Built target catalog1
[ 58%] Built target prepare
[ 61%] Built target basic
[ 63%] Built target datetime
[ 66%] Built target types
[ 69%] Built target desc
[ 72%] Built target blob
[ 75%] Built target keys
[ 77%] Built target bulk
[ 80%] Built target curext
[ 83%] Built target relative
[ 86%] Built target unicode
[ 88%] Built target result1
[ 91%] Built target cursor
[ 94%] Built target error
[ 97%] Built target info
[100%] Built target dyn_cursor
Install the project...
-- Install configuration: "Release"
-- Installing: /usr/local/lib/libmaodbc.so
-- Installing: /usr/local/./share/doc/mariadb_connector_odbc/COPYING
-- Installing: /usr/local/./share/doc/mariadb_connector_odbc/README

======================== Installation successful ==========================

Some of the files created by the installation are inside the home directory: /home

You probably don't want them to be included in the package.
Do you want me to list them?  [n]: n
Should I exclude them from the package? (Saying yes is a good idea)  [n]: n

Copying files to the temporary directory...OK

Stripping ELF binaries and libraries...OK

Compressing man pages...OK

Building file list...OK

Building Debian package...OK

NOTE: The package will not be installed

Erasing temporary files...OK

Writing backup package...OK
OK

Deleting temp dir...OK


**********************************************************************

 Done. The new package has been saved to

 /home/milosz/mariadb-connector-c/mariadb-connector-odbc/mariadb-connector-odbc_3.0.1-1_amd64.deb
 You can install it in your system anytime using: 

      dpkg -i mariadb-connector-odbc_3.0.1-1_amd64.deb

**********************************************************************

Terakhir instal paket yang telah dibuat

$ sudo dpkg -i mariadb-connector-odbc_3.0.1-1_amd64.deb

6. Konfigurasi unixODBC MariaDB Driver

Pertama kita definisikan driver terlebih dahulu.

$ cat << EOF | sudo tee /etc/odbcinst.ini
[MariaDB]
Driver = libmaodbc.so
Description = MariaDB ODBC Connector
EOF

Selanjutnya konfigurasi data source
$ cat << EOF | sudo tee /etc/odbc.ini
[localdb]
Description         = MariaDB localdb
Driver              = MariaDB
Database            = localdb
Server              = 127.0.0.1
Uid                 = milosz
Password            = password
Port                = 3306
EOF

Konfirmasikan bahwa kita dapat terhubung ke data source yang ditentukan.

$ echo | iusql localdb -b

Anda sekarang dapat menjalankan kueri menggunakan lapisan abstraksi Open Database Connectivity.
$ echo "select * from sample_table" | iusql localdb -b
+---------------------------------------------------+
| varchar_column                                    |
+---------------------------------------------------+
| test value                                        |
+---------------------------------------------------+

SQLRowCount returns 1
1 rows fetched

Selesai. Anda memerlukan paket ini untuk memanfaatkan MariaDB menggunakan unixODBC. Pustaka klien MariaDB diperlukan untuk mengompilasinya, Anda tidak perlu menginstalnya di sistem target.
$ ldd /usr/local/lib/libmaodbc.so
linux-vdso.so.1 (0x00007ffc9d1ca000)
libodbcinst.so.2 => /usr/lib/x86_64-linux-gnu/libodbcinst.so.2 (0x00007efe0cee4000)
libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007efe0cbe0000)
libssl.so.1.0.2 => /usr/lib/x86_64-linux-gnu/libssl.so.1.0.2 (0x00007efe0c977000)
libcrypto.so.1.0.2 => /usr/lib/x86_64-linux-gnu/libcrypto.so.1.0.2 (0x00007efe0c513000)
libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007efe0c174000)
libltdl.so.7 => /usr/lib/x86_64-linux-gnu/libltdl.so.7 (0x00007efe0bf68000)
libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007efe0bd4b000)
/lib64/ld-linux-x86-64.so.2 (0x0000558872439000)
libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007efe0bb47000)
All Rights Reserved by Rumah IT - Rumah Teknologi Informasi © 2013 - 2022
Powered By Blogger

Contact Form

Name

Email *

Message *

Powered by Blogger.