Linux

Ubuntu - SQL Server 2012 - Microsoft ODBC 驅動程序 13 - 錯誤:18456,嚴重性:14,狀態:8

  • April 28, 2016

我已經嘗試在 Ubuntu 中執行“Microsoft ODBC Driver 13 for SQL Server”兩天了,但我沒有想法/已經筋疲力盡了Google。

我的測試機器是一個 vagrant 虛擬機,這些是 bash 腳本的相關部分,它充當配置器:

sudo add-apt-repository ppa:ubuntu-toolchain-r/test
sudo apt-get install -y python-software-properties vim curl libgss3 libstdc++6 git-core libpcre3-dev make
sudo apt-get upgrade -y
sudo apt-get dist-upgrade -y

cd /home/vagrant

wget https://download.microsoft.com/download/2/E/5/2E58F097-805C-4AB8-9FC6-71288AB4409D/msodbcsql-13.0.0.0.tar.gz
tar xvzf msodbcsql-13.0.0.0.tar.gz

sudo chmod +x msodbcsql-13.0.0.0/build_dm.sh
sudo chmod +x msodbcsql-13.0.0.0/install.sh

./msodbcsql-13.0.0.0/build_dm.sh --accept-warning

directory=$(ls /tmp | grep 'unixODBC')
path="/tmp/$directory/unixODBC-2.3.1"
cd $(echo $path)
sudo make install

cd /home/vagrant/msodbcsql-13.0.0.0/
sudo ./install.sh install --accept-license

sudo ln -s /usr/lib64/libodbcinst.so.2 /lib/x86_64-linux-gnu/libodbcinst.so.2

cat << EOF | sudo tee -a /home/vagrant/.odbc.ini
[MSSQL]
Description=Microsoft ODBC Driver 13 for SQL Server
Driver=/opt/microsoft/msodbcsql/lib64/libmsodbcsql-13.0.so.0.0
Server=<my_server>\<my_sqlserver_instance_name>,1433
Database=PDS
Threading=1
UsageCount=1
EOF

sudo chown vagrant:vagrant /home/vagrant/.odbc.ini

這是安裝日誌的相關位:

[Fri Apr 22 20:16:59 UTC 2016] Setting permissions on libmsodbcsql-13.0.so.0.0
[Fri Apr 22 20:16:59 UTC 2016] Copying install.sh to /opt/microsoft/msodbcsql/13.0.0.0
[Fri Apr 22 20:16:59 UTC 2016] Setting permissions on install.sh
[Fri Apr 22 20:16:59 UTC 2016] Copying build_dm.sh to /opt/microsoft/msodbcsql/13.0.0.0
[Fri Apr 22 20:16:59 UTC 2016] Setting permissions on build_dm.sh
[Fri Apr 22 20:16:59 UTC 2016] Copying README to /opt/microsoft/msodbcsql/13.0.0.0
[Fri Apr 22 20:16:59 UTC 2016] Setting permissions on README
[Fri Apr 22 20:16:59 UTC 2016] Copying LICENSE to /opt/microsoft/msodbcsql/13.0.0.0
[Fri Apr 22 20:16:59 UTC 2016] Setting permissions on LICENSE
[Fri Apr 22 20:16:59 UTC 2016] Copying WARNING to /opt/microsoft/msodbcsql/13.0.0.0
[Fri Apr 22 20:16:59 UTC 2016] Setting permissions on WARNING
[Fri Apr 22 20:16:59 UTC 2016] Copying INSTALL to /opt/microsoft/msodbcsql/13.0.0.0
[Fri Apr 22 20:16:59 UTC 2016] Setting permissions on INSTALL
[Fri Apr 22 20:16:59 UTC 2016] Copying bin/bcp.rll to /opt/microsoft/msodbcsql/13.0.0.0/en_US
[Fri Apr 22 20:16:59 UTC 2016] Setting permissions on bcp.rll
[Fri Apr 22 20:16:59 UTC 2016] Copying bin/SQLCMD.rll to /opt/microsoft/msodbcsql/13.0.0.0/en_US
[Fri Apr 22 20:16:59 UTC 2016] Setting permissions on SQLCMD.rll
[Fri Apr 22 20:16:59 UTC 2016] Copying bin/BatchParserGrammar.dfa to /opt/microsoft/msodbcsql/13.0.0.0/en_US
[Fri Apr 22 20:16:59 UTC 2016] Setting permissions on BatchParserGrammar.dfa
[Fri Apr 22 20:16:59 UTC 2016] Copying bin/BatchParserGrammar.llr to /opt/microsoft/msodbcsql/13.0.0.0/en_US
[Fri Apr 22 20:16:59 UTC 2016] Setting permissions on BatchParserGrammar.llr
[Fri Apr 22 20:16:59 UTC 2016] Copying lib64/msodbcsqlr13.rll to /opt/microsoft/msodbcsql/13.0.0.0/en_US
[Fri Apr 22 20:16:59 UTC 2016] Setting permissions on msodbcsqlr13.rll
[Fri Apr 22 20:16:59 UTC 2016] Copying docs/en_US.tar.gz to /opt/microsoft/msodbcsql/13.0.0.0/docs/en_US
[Fri Apr 22 20:16:59 UTC 2016] Setting permissions on en_US.tar.gz
[Fri Apr 22 20:16:59 UTC 2016] Copying include/msodbcsql.h to /opt/microsoft/msodbcsql/13.0.0.0/include
[Fri Apr 22 20:16:59 UTC 2016] Setting permissions on msodbcsql.h
[Fri Apr 22 20:16:59 UTC 2016] Extracting documentation from /opt/microsoft/msodbcsql/13.0.0.0/docs/en_US/en_US.tar.gz
...
[Fri Apr 22 20:16:59 UTC 2016] Creating symbolic links
[Fri Apr 22 20:16:59 UTC 2016] Linking bcp to bcp-13.0.0.0
[Fri Apr 22 20:16:59 UTC 2016] Linking sqlcmd to sqlcmd-13.0.0.0
[Fri Apr 22 20:16:59 UTC 2016] Registering the Microsoft ODBC Driver 13 for SQL Server driver
odbcinst: Driver installed. Usage count increased to 1.
   Target directory is /etc

ldd 顯示滿足所有依賴項:

vagrant@vagrant-ubuntu-trusty-64:~$ ldd /opt/microsoft/msodbcsql/lib64/libmsodbcsql-13.0.so.0.0
   linux-vdso.so.1 =>  (0x00007ffd109e8000)
   libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007fde5d698000)
   libodbcinst.so.2 => /lib/x86_64-linux-gnu/libodbcinst.so.2 (0x00007fde5d486000)
   libuuid.so.1 => /lib/x86_64-linux-gnu/libuuid.so.1 (0x00007fde5d280000)
   libgss.so.3 => /usr/lib/libgss.so.3 (0x00007fde5d074000)
   libkrb5.so.3 => /usr/lib/x86_64-linux-gnu/libkrb5.so.3 (0x00007fde5cda9000)
   libcrypto.so.1.0.0 => /lib/x86_64-linux-gnu/libcrypto.so.1.0.0 (0x00007fde5c9cc000)
   libssl.so.1.0.0 => /lib/x86_64-linux-gnu/libssl.so.1.0.0 (0x00007fde5c76d000)
   libstdc++.so.6 => /usr/lib/x86_64-linux-gnu/libstdc++.so.6 (0x00007fde5c460000)
   libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007fde5c159000)
   libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007fde5bf42000)
   libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007fde5bd24000)
   libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007fde5b95e000)
   /lib64/ld-linux-x86-64.so.2 (0x00007fde5dc8e000)
   libltdl.so.7 => /usr/lib/x86_64-linux-gnu/libltdl.so.7 (0x00007fde5b754000)
   libshishi.so.0 => /usr/lib/libshishi.so.0 (0x00007fde5b4fa000)
   libk5crypto.so.3 => /usr/lib/x86_64-linux-gnu/libk5crypto.so.3 (0x00007fde5b2ca000)
   libcom_err.so.2 => /lib/x86_64-linux-gnu/libcom_err.so.2 (0x00007fde5b0c6000)
   libkrb5support.so.0 => /usr/lib/x86_64-linux-gnu/libkrb5support.so.0 (0x00007fde5aebb000)
   libkeyutils.so.1 => /lib/x86_64-linux-gnu/libkeyutils.so.1 (0x00007fde5acb6000)
   libresolv.so.2 => /lib/x86_64-linux-gnu/libresolv.so.2 (0x00007fde5aa9b000)
   libtasn1.so.6 => /usr/lib/x86_64-linux-gnu/libtasn1.so.6 (0x00007fde5a886000)
   libgnutls.so.26 => /usr/lib/x86_64-linux-gnu/libgnutls.so.26 (0x00007fde5a5c8000)
   libgcrypt.so.11 => /lib/x86_64-linux-gnu/libgcrypt.so.11 (0x00007fde5a348000)
   libgpg-error.so.0 => /lib/x86_64-linux-gnu/libgpg-error.so.0 (0x00007fde5a142000)
   libidn.so.11 => /usr/lib/x86_64-linux-gnu/libidn.so.11 (0x00007fde59f0f000)
   libz.so.1 => /lib/x86_64-linux-gnu/libz.so.1 (0x00007fde59cf5000)
   libp11-kit.so.0 => /usr/lib/x86_64-linux-gnu/libp11-kit.so.0 (0x00007fde59ab3000)
   libffi.so.6 => /usr/lib/x86_64-linux-gnu/libffi.so.6 (0x00007fde598ab000)

當我嘗試測試驅動程序時,這是響應:

vagrant@vagrant-ubuntu-trusty-64:~$ isql -v MSSQL sa <password>
[28000][unixODBC][Microsoft][ODBC Driver 13 for SQL Server][SQL Server]Login failed for user 'sa'.
[ISQL]ERROR: Could not SQLConnect

在 SQL Server 錯誤日誌中,我有這個:

2016-04-22 13:35:04.52 Logon       Error: 18456, Severity: 14, State: 8.
2016-04-22 13:35:04.52 Logon       Login failed for user 'sa'. Reason: Password did not match that for the login provided. [CLIENT: <my_ip>]

我可以使用 sa 使用者登錄到命名伺服器,並使用 Microsoft SQL Server Management Studio 登錄“SQL Server 身份驗證”,所以我不認為這是一個“Windows 身份驗證”問題,這似乎是這個錯誤嚴重性的標準答案-狀態組合。

我不知道從這裡去哪裡。任何幫助是極大的讚賞!!!

“Microsoft ODBC Driver 13 for SQL Server”不適用於 isql。您必須使用 sqlcmd。使用 sqlcmd 連接使用 sqlcmd 實用程序比 sqlcmd 手冊頁要好得多。

要使用 DSN:

#sqlcmd -D -S <DSN_Name> -U <User_Name>
sqlcmd -D -S MSSQL -U sa

DSN:

[MSSQL]
Driver=/opt/microsoft/msodbcsql/lib64/libmsodbcsql-13.0.so.0.0
Server=<Server_URI or IP>
Database=<Database_Name>

引用自:https://serverfault.com/questions/772360