Installing ODBC via HomeBrew I installed freetds and unixodbc via Homebrew, more or less following the directions found in this sql server and odbc on Mac link.

I diverged from those directions when it came to the location for the driver and setup, instead using

Driver = /usr/local/Cellar/unixodbc/2.3.2_1/lib/libodbc.dylib
Setup = /usr/local/Cellar/unixodbc/2.3.2_1/lib/libodbc.dylib


in the file /usr/local/Cellar/unixodbc/2.3.2_1/etc/odbcinst.ini since this is where I found my ODBC dynamic libraries.

(I also made those changes because Macs do not use *.so files, that's a *nix nomenclature, which I admit made me nervous in following those directions, but they did seem to match advice at other sites, such as this one for installing RODBC on Mac and these great instructions for *nix.)

I have tried to run it, made changes, done a trace via dtruss, specifically doing this command:

dtruss isql -v odbc-test &lt;my_user_id&gt; &lt;associated_password&gt; 2&gt; junk_to_sift_through.txt


No matter how I adjust things - without actively breaking them further - I keep getting the following error:

[IM004][unixODBC][Driver Manager]Driver's SQLAllocHandle on SQL_HANDLE_HENV failed
[ISQL]ERROR: Could not SQLConnect


The junk_to_sift_through.txt generated file with errors is fairly large, but below is the tail end of it, which should have the error hidden somewhere in it.  But I cannot seem to figure it out.

open_nocancel("/usr/local/Cellar/unixodbc/2.3.2_1/etc/odbcinst.ini\0", 0x0, 0x1B6)       = 3 0
fstat64(0x3, 0x7FFF53378CB8, 0x1B6)      = 0 0
read_nocancel(0x3, "[ms-sql]\nDescription = TDS connection\nDriver = /usr/local/Cellar/unixodbc/2.3.2_1/lib/libodbc.2.dylib\nUsageCount = 1\nFileUsage = 1\nTrace = Yes\n\0", 0x1000)        = 143 0
read_nocancel(0x3, "\0", 0x1000)         = 0 0
close_nocancel(0x3)      = 0 0
open_nocancel("/Users/mike/.odbcinst.ini\0", 0x0, 0x1B6)         = 3 0
fstat64(0x3, 0x7FFF53378CB8, 0x1B6)      = 0 0
read_nocancel(0x3, "[ms-sql]\nDescription = TDS connection\nDriver = /usr/local/Cellar/unixodbc/2.3.2_1/lib/libodbc.2.dylib\nUsageCount = 1\nFileUsage = 1\nTrace = Yes\n\0", 0x1000)        = 143 0
read_nocancel(0x3, "\0", 0x1000)         = 0 0
close_nocancel(0x3)      = 0 0
fstat64(0x1, 0x7FFF5337CD08, 0x1000)         = 0 0
write_nocancel(0x2, "[ISQL]ERROR: Could not SQLConnect\n\0", 0x22)       = 34 0
write_nocancel(0x1, "[IM004][unixODBC][Driver Manager]Driver's SQLAllocHandle on SQL_HANDLE_HENV failed\n\0", 0x53)  = 83 0


Any ideas out there?

Thanks!
unixODBC


  Driver's SQLAllocHandle on SQL_HANDLE_ENV failed


Cause


  The new security features introduced in DB2® Universal Database™ (DB2 UDB) Version 8.2 prevent users from using the database unless they belong to the Windows® groups DB2ADMNS or DB2USERS.


Solution


  Add the userid (the one used to execute the application) to either the DB2ADMNS or DB2USERS group. Please refer to the link under "Related Information" (below) for instructions on how to accomplish this.


Related:


SQLSTATE IM004, SQLAllocHandle on SQL_HANDLE_ENV failed at IBM
Driver's SQLAllocHandle on SQL_HANDLE_HENV failed at Stack Overflow
How do I install RODBC on Mac with unixodbc and freetds?




ODBC Driver for SQL Server

Reinstall the packages using the recent version:

brew tap microsoft/msodbcsql https://github.com/Microsoft/homebrew-mssql-release
ACCEPT_EULA=y brew reinstall --no-sandbox msodbcsql mssql-tools


Note: If you hit multiple tap conflict, run: brew untap microsoft/mssql-preview &amp;&amp; brew untap microsoft/msodbcsql.

Then test your SQL setup by: sqlcmd -S localhost or isql -v -k &lt;connection-string&gt;.

Related: SQL Server : Can't open lib 'ODBC Driver 13 for SQL Server'.

See: Installing the Microsoft ODBC Driver for SQL Server on Linux and macOS.