SQL Server:无法通过ODBC驱动程序进行连接

时间:2019-03-10 09:38:42

标签: node.js sql-server docker odbc

我正在尝试使用Docker通过ODBC驱动程序连接到Azure上的SQL Server数据库。我遵循Microsoft(https://docs.microsoft.com/en-us/sql/connect/odbc/linux-mac/installing-the-microsoft-odbc-driver-for-sql-server?view=sql-server-2017#ubuntu-1604-1)的官方文档,但收到错误消息:

  

错误:[unixODBC] [驱动程序管理器]无法打开lib'/opt/microsoft/msodbcsql/lib64/libmsodbcsql-13.1.so.9.2':找不到文件    错误:
  消息:'[unixODBC] [驱动程序管理器]无法打开lib \'/ opt / microsoft / msodbcsql / lib64 / libmsodbcsql-13.1.so.9.2 \:找不到文件',状态:'01000'
  错误:“ [node-odbc] SQL_ERROR”
  '[unixODBC] [驱动程序管理器]无法打开lib \'/ opt / microsoft / msodbcsql / lib64 / libmsodbcsql-13.1.so.9.2 \:找不到文件”,状态:“ 01000”

当我检查是否使用odbcinst -j安装了驱动程序时,我得到:

unixODBC 2.3.7
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

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.9.2
UsageCount=1

有人暗示我可能会错过什么吗?在我的Mac本地,我可以连接到数据库并执行查询,但是不能使用Docker。

Dockerfile:

FROM node:10
RUN apt-get update
RUN apt-get install --yes curl
RUN curl https://packages.microsoft.com/keys/microsoft.asc | apt-key add -
RUN curl https://packages.microsoft.com/config/ubuntu/16.04/prod.list > /etc/apt/sources.list.d/mssql-release.list

RUN apt-get install -y build-essential
RUN apt-get install -y make
RUN apt-get install -y apt-transport-https
RUN apt-get update && ACCEPT_EULA=Y apt-get install -y msodbcsql unixodbc unixodbc-dev 
RUN echo 'export PATH="$PATH:/opt/mssql-tools/bin"' >> ~/.bash_profile
RUN echo 'export PATH="$PATH:/opt/mssql-tools/bin"' >> ~/.bashrc
# RUN source ~/.bashrc
RUN apt-get install -y unixodbc-dev
ADD . /var/www/app
WORKDIR /var/www/app
RUN npm install && \
    npm cache clean --force
RUN npm run build 
EXPOSE 3000:80

0 个答案:

没有答案