I am attempting to get Ubuntu 22.04 to talk to mssql server on my Windows machine. The same machine hosting the WSL2 Ubuntu distro. I have installed unixodbc. The odbc.ini file is as follows:
[MYDSN]
Driver="ODBC Driver 18 for SQL Server"
Server=192.168.1.100
Port=1433
Database=mydb
My odbinst.ini file looks like this:
[ODBC Driver 18 for SQL Server]
Description=Microsoft ODBC Driver 18 for SQL Server
Driver=/opt/microsoft/msodbcsql18/lib64/libmsodbcsql-18.3.so.2.1
UsageCount=1
When I execute sudo odbcinst -j I get the following:
DRIVERS............: /etc/odbcinst.ini
SYSTEM DATA SOURCES: /etc/odbc.ini
FILE DATA SOURCES..: /etc/ODBCDataSources
USER DATA SOURCES..: /root/.odbc.ini
SQLULEN Size.......: 8
SQLLEN Size........: 8
SQLSETPOSIROW Size.: 8
However, when I execute:
isql -v MYDSN sa "mypassword"
I get the following:
[IM002][unixODBC][Driver Manager]Data source name not found and no default driver specified
[ISQL]ERROR: Could not SQLConnect
I am able to ping the IP address of SQL Server. I have port 1433 open on the Windows firewall and SQL Server is setup to allow remote connections and is using TCP/IP.
In my troubleshooting I failed to go back and remove the quotes from the following:
in the
odbc.inias suggested by AlwaysLearning.Once I removed the quotes, I received a different error:
This was fixed by adding
Encrypt=noto theodbc.inifile. I found the answer to this issue here. I can now connect to SQL Server using iSQL.