1

I successfully installed the offical MSSQL ODBC drivers in Linux and I can connect to every database and execute commands with isql:

sudo isql -v dsn user pw

However, if I execute a SQL statement (select ...) in my own application it is not possible to fetch data ("Driver does not support this function") -> I think it is because isql needs sudo rights.

Is there any way to execute isql without sudo? I tried to change (chmod, chown) some rights for isql, but I still need sudo.

J0eBl4ck
  • 415
  • 1
  • 4
  • 10

2 Answers2

2

I found the solution. The problem was not isql, but the location of odbc.ini and odbcinst.ini!

As "sudo" the connection is looking at /etc/odbc.ini and /etc/odbcinst.ini

As "normal" user the connection is looking at a path like that: /usr/local/odbc.ini and /usr/local/odbcinst.ini

I edited both files and the connection worked!

J0eBl4ck
  • 415
  • 1
  • 4
  • 10
  • Trying this on a Mac, but just moving the files from `/etc/odbc.ini` to either `/usr/local/odbc.ini` or `/usr/local/etc/odbc.ini` (and the same for the inst file) didn't work for me. Did you have to do something else as well? – Adrian Keister Aug 27 '19 at 21:58
  • I can put the files in `/usr/local/etc/`, and even `chown` and `chmod` to my heart's content, but it doesn't allow me to `isql` without `sudo`. – Adrian Keister Aug 27 '19 at 22:12
  • Answered my own question. For some reason, the `cp` or `mv` command didn't quite do what I expected. When I made sure the actual file content was correct, it finally worked. On a Mac, it appears that the files need to be in BOTH `/usr/local/etc/` and `/etc/`. That's probably a bug. – Adrian Keister Aug 27 '19 at 22:46
0

this should not be the case. Can you try a SELECT @@Version? Alternatively, can you try running the same query via sqlcmd?

Steps to install and run sqlcmd are here: https://blogs.msdn.microsoft.com/sqlnativeclient/

meet-bhagdev
  • 2,608
  • 18
  • 22