Sunday, February 4, 2024

.::: Install MariaDB ODBC Driver on Linux & test DSN or odbcins.ini and odbc.ini :::.

 
1. Install mariadb connector odbc
[root@teguhth ~]# yum install -y https://dlm.mariadb.com/3680404/Connectors/odbc/connector-odbc-3.1.20/mariadb-connector-odbc-3.1.20-centos74-amd64.rpm

2. check rpm odbc

[root@teguhth ~]# rpm -qa | grep -i odbc
msodbcsql18-18.3.2.1-1.x86_64
mariadb-connector-odbc-3.1.20-1.x86_64
postgresql-odbc-09.03.0100-2.el7.x86_64
unixODBC-devel-2.3.11-1.rh.x86_64
unixODBC-2.3.11-1.rh.x86_64
[root@teguhth ~]#


3. check driver mariadb
[root@teguhth ~]# cat /etc/odbcinst.ini
[PostgreSQL]
Description=ODBC for PostgreSQL
Driver=/usr/lib/psqlodbcw.so
Setup=/usr/lib/libodbcpsqlS.so
Driver64=/usr/lib64/psqlodbcw.so
Setup64=/usr/lib64/libodbcpsqlS.so
FileUsage=1

[MySQL]
Description=ODBC for MySQL
Driver=/usr/lib/libmyodbc5.so
Setup=/usr/lib/libodbcmyS.so
Driver64=/usr/lib64/libmyodbc5.so
Setup64=/usr/lib64/libodbcmyS.so
FileUsage=1

[ODBC Driver 18 for SQL Server]
Description=Microsoft ODBC Driver 18 for SQL Server
Driver=/opt/microsoft/msodbcsql18/lib64/libmsodbcsql-18.3.so.2.1
UsageCount=1

[MariaDB]
Driver=/usr/lib64/libmaodbc.so
DESCRIPTION=MariaDB ODBC Connector
Threading=0
UsageCount=1


[root@teguhth ~]#

4. check odbc ini

[MariaDBDSN]
Description = My MariaDB DSN
Driver      = MariaDB
Server      = 10.10.10.8
Port        = 3306
Database    = teguhth
User        = admin
Password    = admin
Option      = 3

example

[root@teguhth ~]# cat /etc/odbc.ini

[edbdb]
Description         = PostgreSQL connection to SallyDB
Driver              = PostgreSQL
Database            = teguhth
Servername          = 10.10.10.8
UserName            = admin
Password            = admin
Port                = 5432
ReadOnly            = No
RowVersioning       = No
ShowSystemTables    = No
#ConnSettings        =

[MariaDBDSN]
Description = My MariaDB DSN
Driver      = MariaDB
Server      = 10.10.10.8
Port        = 3306
Database    = teguhth
User        = admin
Password    = admin
Option      = 3
[root@teguhth ~]#


5. test login

[root@teguhth ~]# isql -v MariaDBDSN
+---------------------------------------+
| Connected!                            |
|                                       |
| sql-statement                         |
| help [tablename]                      |
| echo [string]                         |
| quit                                  |
|                                       |
+---------------------------------------+
SQL> select * from barang;
+------------+--------------------------+---------------------+------------+
| KODE_BARANG| NAMA_BARANG              | SATUAN_BARANG       | STOK_BARANG|
+------------+--------------------------+---------------------+------------+
| ELK-01     | RICE COOKER              | BUAH                | 20         |
| ELK-02     | LEMARI ES                | UNIT                | 8          |
| ELK-03     | TELEVISI                 | UNIT                | 30         |
| ELK-04     | RADIO/TAPE               | BUAH                | 35         |
| ELK-05     | KOMPUTER                 | UNIT                | 28         |
| ELK-06     | KIPAS ANGIN              | BUAH                | 38         |
| ELK-07     | KIPAS ANGIN              | BUAH                | 38         |
+------------+--------------------------+---------------------+------------+
SQLRowCount returns 7
7 rows fetched
SQL> select @@hostname,@@version;
+-----------+--------------------+
| @@hostname| @@version          |
+-----------+--------------------+
| teguhth   | 10.11.6-MariaDB-log|
+-----------+--------------------+
SQLRowCount returns 1
1 rows fetched
SQL>

 


No comments:

Post a Comment

Popular Posts