Below are some hurdles I had to jump over to get ODBC and JDBC working when connecting to mySQL server on Debian 12:
Download ODBC Drivers directly from dev.mysql.com: https://dev.mysql.com/downloads/connector/odbc/
Make sure you choose "Linux - Generic" under "Select Operating System".
- copy the file libmyodbc8a.so to /usr/lib/x86_64-linux-gnu/odbc/
- copy the file libmyodbc8w.so to /usr/lib/x86_64-linux-gnu/odbc/
*The name/versions of these files may change with updates.
then, create file /etc/odbcinst.ini ⇒ sudo nano /etc/odbcinst.ini
[MySQL]
Description = ODBC for MySQL
Driver = /usr/lib/x86_64-linux-gnu/odbc/libmyodbc9a.so ‡
Setup = /usr/lib/x86_64-linux-gnu/odbc/libodbc9w.so
FileUsage = 1
and create file /etc/odbc.ini ⇒ sudo nano /etc/odbc.ini
[my-connector]
Description = MySQL connection to database
Driver = MySQL (‡ see note below)
Database = eik
Server = localhost
User = root
Password =
Port = 3306
#Socket = /opt/lampp/var/mysql/mysql.sock
Socket = /run/mysqld/mysql.sock
echo "select 1" | isql -v my-connector
- Duplicate above for separate databases you wish to connect to e.g.
[anotherdb] Description = MySQL connection to database Driver =
Driver = /usr/lib/x86_64-linux-gnu/odbc/libmyodbc9a.soDatabase = testdb Server = localhost User = root Password = Port = 3306 Socket = /run/mysqld/mysql.sock
echo "select 1" | isql -v anotherdb
- Note the location of the mysqld may vary and the commented out string is for xampp
- You can find your running mysql daemon location with this command: sudo find / -type s
- Edit /etc/odbc.ini to include the correct path.
To connect to ODBC/JDBC in LibreOffice Base:
- "Connect to an existing database": MySQL/MariaDB
- "Connect using ODBC (Open Database Connectivity"
- "Browse" (button in the next dialog should show the configured ODBC connections in /etc/odbc.ini).
- Select User Name: usually root
- Select Password required checkbox if password not blank.
If you get an error:
"Could not load the program library libodbc.so or it is corrupted. The ODBC data source selection is not available."
sudo apt-get install odbc-mdbtools
‡ If you get an error:
"[unixODBC][Driver Manager]Data source name not found and no default driver specified at ./connectivity/source/drivers/odbc/OTools.cxx:357"
Look in the file /etc/odbcinst.ini and copy Driver = /usr/lib/x86_64-linux-gnu/odbc/libmyodbc9a.so to Driver = ‡ in /etc/odbc.ini
ODBC doesn't display Japanese characters, but JDBC does!
(ODBCでは日本語の文字は表示されませんが、JDBCでは表示されます)
JDBC connect
- sudo apt install default-jdk
- sudo apt install libmariadb-java
- Download : https://dev.mysql.com/downloads/connector/j/ for Debian Linux
- sudo dpkg -i mysql-connector-j_9.0.0-1debian12_all.deb
Database Connection Wizard (in LibreOffice Base):
- "Connect to an existing database": MySQL/MariaDB
- "Connect using JDBC (Java Database Connectivity"
- Enter Database Name:
- Server: localhost
- Port: 3306
- You should see org.mariadb.jdbc.Driver in the Window:
MySQL/MariaDB JDBC Driver Class
Notes:
- Check ODBC INST with command: odbcinst -j
- https://forums.linuxmint.com/viewtopic.php?p=2158370&hilit=odbc#p2158370
- https://bugs.launchpad.net/ubuntu/+source/libreoffice/+bug/1858165
- A few weeks later I was suddenly presented with an error message when trying to connect via both JDBC and ODBC.
- “LibreOffice requires a Java runtime environment (JRE) to perform this task. The selected JRE is defective. Please select another version or install a new JRE and select it under Tools - Options - LibreOffice - Java.”
- I resolved this by $ sudo apt install default-jre default-jre-headless