gpt4 book ai didi

odbcinst : SQLGetPrivateProfileString failed with Unable to find component name

转载 作者:行者123 更新时间:2023-12-05 04:08:35 31 4
gpt4 key购买 nike

我的默认用户可以毫无问题地使用 unixodbc。但是当我切换到另一个用户时,出现错误。

[centos@ ~]$ odbcinst -q -s
[ODBC]
[Amazon Redshift DSN 32]

[centos@ ~]$ su ruser
Password:
[ruser@ centos]$ odbcinst -q -s
odbcinst: SQLGetPrivateProfileString failed with Unable to find component name.

两个用户都设置了环境变量:

AMAZONREDSHIFTODBCINI=/etc/amazon.redshiftodbc.ini
ODBCSYSINI=/usr/local/odbc
ODBCINI=/etc/odbc.ini
LD_LIBRARY_PATH=/usr/local/lib
LD_PRELOAD=/usr/local/lib/libodbcinst.so

odbc配置如下:

[ruser@ centos]$ odbcinst -j
unixODBC 2.3.4
DRIVERS............: /usr/local/odbc /odbcinst.ini
SYSTEM DATA SOURCES: /usr/local/odbc /odbc.ini
FILE DATA SOURCES..: /usr/local/odbc /ODBCDataSources
USER DATA SOURCES..: /etc/odbc.ini
SQLULEN Size.......: 8
SQLLEN Size........: 8
SQLSETPOSIROW Size.: 8

对了,我不明白为什么上面的路径会有空格。我不知道是否有办法改变它们。有解决这个问题的想法吗?两个用户的总体 odbc 配置似乎相同。

最佳答案

我在 Centos 上发现了完全相同的问题,我可以使用默认的 centos 用户进行连接,但不能使用任何其他用户。

我能够通过将工作用户(或系统)odbc.iniodbcinst.ini 文件复制到其他用户的主目录中来解决问题,就像这样(我已将它们分别重命名为 .odbc.ini.odbcinst.ini):

~/.odbc.ini

[MSSQLTest]
Driver = ODBC Driver 17 for SQL Server
Server = tcp:<ip of server>

~/.odbcinst.ini

[ODBC Driver 17 for SQL Server]
Description=Microsoft ODBC Driver 17 for SQL Server
Driver=/opt/microsoft/msodbcsql17/lib64/libmsodbcsql-17.2.so.0.1
UsageCount=1

最后,我只需设置以下 environment variables在我的 ~/.bashrc 文件中,我能够连接。

export ODBCSYSINI="<full path to user folder, which would be the evaluated path of {echo ~}>"
export ODBCINSTINI=".odbcinst.ini"
export ODBCINI="<full path to user folder, which would be the evaluated path of {echo ~}>/.odbc.ini"

出于某种原因,我无法使用 ~ 来引用用户文件夹,所以我不得不在环境变量中手动指定完整的用户路径,因此我的完整 .bashrc 文件很简单:

export ODBCSYSINI="/home/mitch"
export ODBCINSTINI=".odbcinst.ini"
export ODBCINI="/home/mitch/.odbc.ini"

通过此设置,我现在可以运行以下命令并成功连接:

$ isql -v MSSQLTest <sql server username> <sql server password>
+---------------------------------------+
| Connected! |
| |
| sql-statement |
| help [tablename] |
| quit |
| |
+---------------------------------------+
SQL>

关于odbcinst : SQLGetPrivateProfileString failed with Unable to find component name,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47268199/

31 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com