Installing ODBC via HomeBrew
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.