Linux 在 Unix 上测试 ODBC 条目
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/9945721/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Test ODBC entry on Unix
提问by Diego
Does anyone know a way of testing if an odbc entry on the odbc.ini file is configured correctly?
有谁知道一种测试 odbc.ini 文件中的 odbc 条目是否配置正确的方法?
I would like to know if my linux server is able to connect to my SQL Server using an ODBC entry I configured.
我想知道我的 linux 服务器是否能够使用我配置的 ODBC 条目连接到我的 SQL Server。
采纳答案by bohica
If you are using unixODBC as the ODBC driver manager then just do:
如果您使用 unixODBC 作为 ODBC 驱动程序管理器,那么只需执行以下操作:
isql -v mydsn myusername mypassword
回答by ton
The most common problem is that the default source build setup is set to /usr/local/etc
, not /etc
, so you (as me) may be look at a nice config file but unused.
最常见的问题是默认的源构建设置设置为/usr/local/etc
,而不是/etc
,因此您(和我一样)可能会查看一个不错的配置文件但未使用。
To verify it, just run
要验证它,只需运行
# odbc_config --odbcinstini
/usr/local/etc/odbcinst.ini
A simple symbolic link solve it.
一个简单的符号链接解决它。
Another problem can be a missing library, that you can verify by running the ldd
. ex:
另一个问题可能是缺少库,您可以通过运行ldd
. 前任:
# ldd /opt/microsoft/sqlncli/lib64/libsqlncli-11.0.so.1790.0 | grep "not found"
libodbcinst.so.1 => not found
In this case, I need to put the libodbcinst.so.1 in LD_LIBRARY_PATH
or in any directory in use by /etc/ld.so.conf
.
If you choose to put in ld directories, do not forget to run ldconfig
as root after it to update ldd cache file.
在这种情况下,我需要把libodbcinst.so.1中LD_LIBRARY_PATH
通过或在任何目录中使用/etc/ld.so.conf
。如果您选择放入 ld 目录,请不要忘记ldconfig
在更新 ldd 缓存文件后以 root身份运行。