Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SQL server ODBC driver linux username ''

I installed the Microsoft SQL server ODBC driver for linux version 13.

I can login with username password commandline but not with the username and password within odbc.ini

Example

curl https://packages.microsoft.com/config/rhel/6/prod.repo > /etc/yum.repos.d/mssql-release.repo                                                                                                                                                                                                     yum install msodbcsql mssql-tools

[root@server01 etc]# cat odbc.ini

[MY_ODBC_DSN]

Driver = ODBC Driver 13 for SQL Server

Server = tcp:10.10.10.1,1433

Database = demo

UID = user1

PWD = password

Does work

isql -v MY_ODBC_DSN user1 password

Doesn't Work

isql -v MY_ODBC_DSN

[28000][unixODBC][Microsoft][ODBC Driver 13 for SQL Server][SQL Server]Login failed for user ''.
[ISQL]ERROR: Could not SQLConnect
like image 667
Patrick Transfer Avatar asked Feb 22 '17 09:02

Patrick Transfer


People also ask

How do I find my ODBC driver name?

To check the ODBC SQL Server driver version (32-bit ODBC): In Administative Tools, double-click Data Sources (ODBC). Click the Drivers tab. Information for the Microsoft SQL Server entry is displayed in the Version column.

How do I find my DSN name in Linux?

For unixODBC, DSNs are listed in /usr/local/etc/odbc. ini . Installed ODBC drivers will be listed in /usr/local/etc/odbcinst.


1 Answers

@Patrick, you can not read username and password from odbc.ini. I tried this with sqlcmd and here is how I verified it.

sudo su
curl https://packages.microsoft.com/config/ubuntu/16.04/prod.list > /etc/apt/sources.list.d/mssql-tools.list
exit
sudo apt-get update
sudo ACCEPT_EULA=Y apt-get install mssql-tools unixodbc-dev
echo 'export PATH="$PATH:/opt/mssql-tools/bin"' >> ~/.bash_profile
echo 'export PATH="$PATH:/opt/mssql-tools/bin"' >> ~/.bashrc
source ~/.bashrc

odbcinst.ini

[ODBC Driver 13 for SQL Server]
Description=Microsoft ODBC Driver 13 for SQL Server
Driver=/opt/microsoft/msodbcsql/lib64/libmsodbcsql-13.1.so.4.0
UsageCount=1

odbc.ini

[TestDB]
Server=myserver
Driver=ODBC Driver 13 for SQL Server

sqlcmd

sqlcmd -D -S TestDB -U myusername -P mypassword

If you would like to use integrated auth, check this out:

https://docs.microsoft.com/en-us/sql/connect/odbc/linux/using-integrated-authentication
like image 192
meet-bhagdev Avatar answered Sep 24 '22 06:09

meet-bhagdev