1

I was following the instructions for registering a driver and data source given here: "Installing Connector/ODBC from a Binary Tarball Distribution"

After realizing I had to use sudo when running myodbc-installer, I could successfully get the driver I installed to show as registered, with:

shell> myodbc-installer -d -l
MySQL ODBC 8.0 Driver

When you run myodbc-installer with no arguments, it lists the command line switches and also tells you how to register a data source. The example it gives is:

Add a new system data source name for Unicode driver              
shell> myodbc-installer -s -a -c2 -n "test" \                  
           -t "DRIVER=MySQL ODBC 8.0 Unicode Driver;SERVER=localhost;DATABASE=test;UID=myid;PWD=mypwd"

That didn't exactly match the name (it's MySQL ODBC 8.0 Driver, not MySQL ODBC 8.0 Unicode Driver... the ASCII driver is merely MySQL ODBC 8.0 )

But using the appropriate driver name, I managed to get the installer to successfully register a data source, which could be listed back:

shell> myodbc-installer -s -l
test                  - MySQL ODBC 8.0 Driver

But the program I tried to use this DSN with wasn't working. So I thought I would look for some simpler case to try. The iodbctest program seemed like a good candidate, as it has a function where you hit ? and it lists the data sources. But I don't get anything...

shell> iodbctest
iODBC Demonstration program
This program shows an interactive SQL processor
Driver Manager: 03.52.0812.0326

Enter ODBC connect string (? shows list): ?

DSN                              | Driver                                  
------------------------------------------------------------------------------

Enter ODBC connect string (? shows list):

Since sudo helped with the installation process, I thought I'd try sudo iodbctest, but that did not help.

Salvatore
  • 10,815
  • 4
  • 31
  • 69

1 Answers1

0

So I thought I would look for some simpler case to try. The iodbctest program seemed like a good candidate, as it has a function where you hit ? and it lists the data sources.

Don't mix installs of iodbc and unixodbc. iodbc isn't an abstract set of tools and tests for ODBC, it is a completely independent implementation of ODBC from unixodbc.

In my case, I first installed unixodbc. So that's what myodbc-installer asked to register the drivers and data sources, via shared library functions. But it wrote the .INI files in a way that doesn't match what iodbc would have written.

Case in point: the iodbctest client appears to not be dynamically linked to use whatever ODBC provider is on your system. It is statically linked to iodbc routines that look explicitly in the odbc.ini file for an [ODBC Data Sources] section. This index does not appear to be made automatically by the unixodbc registration process.

(Note: This may be a bug in either unixodbc or mysql-installer's usage of it, as the documentation says "An [ODBC Data Sources] section is maintained in each odbc.ini and may or may not be used by the odbcinst library.")

Interestingly, while the mysql-installer tells you how to use it to register a data source, a different suggestion on the MySQL website tells you to edit the INI file by hand. This contradicts what unixodbc says, which is "NOTE: odbc.ini and odbcinst.ini are considered to be ODBC System Information. All access (read or write) to this System Information should occur via the Driver Manager or the ODBCINST share library. Do not access these INI files directly!" (emphasis theirs)

Beyond the issue of not being able to get the index, even if you do connect to a data source on Linux, iODBC uses wchar_t and not SQLWCHAR. So with a unicode driver, you'll get a bunch of gibberish back from your queries.