SQL server ODBC驱动程序linux用户名''

时间:2017-02-22 09:10:07

标签: sql-server linux odbc driver

我为linux版本13安装了Microsoft SQL Server ODBC驱动程序。

我可以使用用户名密码命令行登录,但不能使用odbc.ini

中的用户名和密码登录

实施例

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

有效吗

isql -v MY_ODBC_DSN user1 password

不能工作

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

1 个答案:

答案 0 :(得分:1)

@Patrick,你无法从odbc.ini读取用户名和密码。我用sqlcmd尝试了这个,这是我验证它的方式。

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

如果您想使用集成身份验证,请查看:

https://docs.microsoft.com/en-us/sql/connect/odbc/linux/using-integrated-authentication