Register an ODBC Driver Safely in odbcinst.ini
You will add a named ODBC driver entry to /etc/odbcinst.ini, check that its shared-library paths are real, and know how an application refers to the entry. Allow about fifteen minutes if the driver package is already installed. The examples use unixODBC 2.3.12, matching the unixodbc-common package and installed odbcinst.ini(5) manual on this machine.
The route
Jump straight to the step you need, or tick off Done means at the end.
You need shell access, the driver library supplied by your database vendor, and permission to edit the system configuration. Editing /etc/odbcinst.ini requires elevated privileges. Do not guess a driver path from a blog post: library locations differ between distributions, architectures and driver packages.
1. Check the installed files and package version
Start with read-only checks. This confirms the configuration file you are about to change and records the local unixODBC version:
$ ls -l /etc/odbcinst.ini
$ dpkg-query -W -f='${Package} ${Version}\n' unixodbc-common unixodbc 2>/dev/null || true
$ command -v odbcinst || true
On this host the package version is 2.3.12-1ubuntu0.24.04.1. The odbcinst command is not present here because the command-line utility is packaged separately from the installed manual. If it is available on your system, the manual recommends it for installing a template. Otherwise, a careful manual edit is valid.
Checkpoint: identify the actual driver library before touching the configuration. If the vendor package provides a template, inspect it with less. For a candidate path, use:
$ test -r /path/to/vendor-driver.so && echo "driver library is readable"
$ file /path/to/vendor-driver.so
Replace the placeholder with the path supplied by your driver package. A readable file is not proof that every dependency loads, but a missing file guarantees failure later.
2. Preserve the current configuration
Before making a system-wide change, create a backup with a timestamp. This is an elevated command because the file belongs under /etc:
$ sudo cp --preserve=mode,ownership,timestamps /etc/odbcinst.ini \
"/etc/odbcinst.ini.backup.$(date +%Y%m%d-%H%M%S)"
Record the backup name printed by your shell history or list it explicitly:
$ ls -l /etc/odbcinst.ini.backup.*
Do not use shell redirection directly on the live file. A failed command or a mistyped path can truncate it. The backup is the recovery point if an application stops finding a driver.
3. Add one named driver section
Use an editor with elevated privileges and add a section whose name is stable and easy to type. The section name is the value an ODBC data-source configuration will later use as its Driver value:
[Example Vendor ODBC]
Description = Example Vendor ODBC driver
Driver = /path/to/vendor-driver.so
Setup = /path/to/vendor-setup.so
FileUsage = 1
For example:
$ sudoedit /etc/odbcinst.ini
Description is a human-readable label. Driver names the actual driver library. Setup names the optional setup library used by configuration tools. Keep FileUsage only when the driver documentation supplies it, and copy the driver-specific value exactly. Some drivers instead require architecture-specific Driver64 or Setup64 entries.
Do not copy the PostgreSQL paths from the manual as if they were universal. Its example uses /usr/lib/psqlodbcw.so and /usr/lib/libodbcpsqlS.so, but your distribution may install different names or multi-architecture paths.
4. Validate the section before using it
Read back only the relevant section and check every referenced file. These commands do not change configuration:
$ awk '/^\[Example Vendor ODBC\]/{show=1} show{print} show && /^\[/{seen++} seen > 1{exit}' /etc/odbcinst.ini
$ test -r /path/to/vendor-driver.so && echo "driver path OK"
$ test -r /path/to/vendor-setup.so && echo "setup path OK"
The exact section output should contain the name you chose and the paths you intended. If a setup library is not supplied by the vendor, remove that line rather than inventing one. A driver manager may load the driver later, when an application connects, so this check catches configuration mistakes but is not a complete connection test.
When odbcinst is installed, its template workflow is the documented alternative. Put the same section in a separate template file, then run the command as an administrator:
$ sudo odbcinst -i -d -f /path/to/template.ini
That command changes the system driver registry. Review the template first and keep the backup. Do not run it repeatedly without checking what it adds.
5. Refer to the driver from a data source
An ODBC data-source configuration refers to the section by name, not by repeating the shared-library path. The essential relationship is:
[Reporting]
Driver = Example Vendor ODBC
The name must match the section header exactly, including spaces and capitalisation. The driver section belongs in odbcinst.ini; a data-source section belongs in odbc.ini or in the application-specific configuration. Keeping those roles separate makes a missing driver easier to diagnose.
6. Enable tracing only for a bounded investigation
The special [ODBC] section controls unixODBC driver tracing. Enable it only when you need diagnostic output, and choose a path that is not writable by multiple users:
[ODBC]
Trace = Yes
TraceFile = /var/tmp/odbc-trace.log
Trace is enabled by a value containing 1, y, yes or on, in any case. TraceFile does nothing unless tracing is enabled; if omitted, the documented default is /tmp/sql.log. Traces can contain connection details and query data, so protect the file and remove the setting after the incident.
To undo this diagnostic change, edit the section and remove or disable both lines, then remove the trace file only after checking that no process is still writing it. Do not leave tracing enabled on a busy or sensitive system.
Common failures and recovery
- Driver not found: the
Drivervalue is a path, not a package name. Check it withls -land compare it with the vendor package contents. - Data source cannot find the driver: check that its
Drivervalue is the exact section name, not the library path. - Setup errors: a setup library and a driver library are separate files. Follow the vendor template and do not point both keys at an arbitrary shared object.
- Unexpected behaviour after an edit: restore a known-good backup with
sudo cp --preserve=all /etc/odbcinst.ini.backup.YYYYMMDD-HHMMSS /etc/odbcinst.ini, replacing the placeholder with the exact backup file you created.
Done means
/etc/odbcinst.inicontains one named section for the installed driver.- The
Driverpath exists and the section name matches the data-source configuration. - A dated backup exists before the change.
- Tracing is disabled unless it is actively needed, and any trace file has suitable ownership and permissions.