odbcinst:SQLGetPrivateProfileString 失败,无法找到组件名称 [英] odbcinst: SQLGetPrivateProfileString failed with Unable to find component name
问题描述
我可以使用 unixodbc 而我的默认用户没有任何问题.但是当我切换到另一个用户时,我收到一个错误.
I am able to use unixodbc without any problem with my default user. But when I switch to another user, I get an error.
[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.
在两个用户中都设置了环境变量:
Environment variables are set in both of the users:
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 配置似乎相同.
By the way, I don't understand why there are spaces in the above paths. I don't know if there is a way to change them. Any ideas to solve this issue? Overall odbc configuration seems the same in both of the users.
推荐答案
我在 Centos 上发现了完全相同的问题,我可以使用默认的 centos
用户进行连接,但不能使用任何其他用户.
I found the exact same issue on Centos, where I could use the default centos
user to connect, but not any other users.
我能够通过将工作用户(或系统)odbc.ini
和 odbcinst.ini
文件复制到另一个用户的主目录中来解决该问题,就像这样(我已经将它们分别重命名为 .odbc.ini
和 .odbcinst.ini
):
I was able to resolve the issue by copying the working user (or system) odbc.ini
and odbcinst.ini
files across into the home directory of the other user, like so (where I have renamed them to .odbc.ini
and .odbcinst.ini
respectively):
~/.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
最后,我只需要设置以下环境变量 在我的 ~/.bashrc
文件中,我能够连接.
Finally, I just had to set the following environment variables inside my ~/.bashrc
file, and I was able to connect.
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
文件很简单:
For some reason, I wasn't able to use ~
to reference the user folders, so I had to manually specify the full user path in the environment variables, and thus my complete .bashrc
file is simply:
export ODBCSYSINI="/home/mitch"
export ODBCINSTINI=".odbcinst.ini"
export ODBCINI="/home/mitch/.odbc.ini"
通过此设置,我现在可以运行以下命令并成功连接:
With this setup, I could now run the following and connect successfully:
$ isql -v MSSQLTest <sql server username> <sql server password>
+---------------------------------------+
| Connected! |
| |
| sql-statement |
| help [tablename] |
| quit |
| |
+---------------------------------------+
SQL>
这篇关于odbcinst:SQLGetPrivateProfileString 失败,无法找到组件名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!