im004错误

o4tp2gmn  于 2021-06-18  发布在  Mysql
关注(0)|答案(0)|浏览(482)

在我的mac上,我试图用unixodbc(v。2.3.7)。 odbcinst -j 显示:

DRIVERS............: /usr/local/etc/odbcinst.ini
SYSTEM DATA SOURCES: /usr/local/etc/odbc.ini
FILE DATA SOURCES..: /usr/local/etc/ODBCDataSources
USER DATA SOURCES..: /Users/homer/.odbc.ini
SQLULEN Size.......: 8
SQLLEN Size........: 8
SQLSETPOSIROW Size.: 8

部分内容 ~/.odbc.ini 以及 /usr/local/etc/odbc.ini :

[mysql-local]
description     = local server
Driver          = MySQLDriver
SERVER          = localhost
USER            = testuser
PASSWORD        = testpass
DATABASE        = testdb

部分内容 /usr/local/etc/odbcinst.ini ```
[MySQLDriver]
Driver = /usr/local/lib/libodbc.dylib
Setup = /usr/local/lib/libodbc.dylib
FileUsage = 1

驱动程序/设置文件链接到一个链接到实际驱动程序的文件: `/usr/local/Cellar/unixodbc/2.3.7/lib/libodbc.2.dylib` . 我已经把这个文件的烫发数设为755。
然后我尝试连接:

isql mysql-local testuser testpass -v

结果是:

[IM004][unixODBC][Driver Manager]Driver's SQLAllocHandle on SQL_HANDLE_HENV failed
[ISQL]ERROR: Could not SQLConnect

因为某种原因我有 `osql` ,web告诉我它是用来连接到sql server的(我可以用它来验证 `.ini` 正在正确分析文件。因此

osql -I /usr/local/etc -S mysql-local -U testuser -P testpass

结果:

"" is NOT a directory, overridden by
"/usr/local/etc".
checking odbc.ini files
reading /Users/homer/.odbc.ini
[mysql-local] found in /Users/homer/.odbc.ini
found this section:
[mysql-local]
description = local server
Driver = MySQLDriver
Server = 127.0.0.1
USER = testuser
PASSWORD = testpass
DATABASE = testdb
looking for driver for DSN [mysql-local] in /Users/homer/.odbc.ini
found driver line: " Driver = MySQLDriver"
driver "MySQLDriver" found for [mysql-local] in .odbc.ini
found driver named "MySQLDriver"
"MySQLDriver" is not an executable file
looking for entry named [MySQLDriver] in /usr/local/etc/odbcinst.ini
found driver line: " Driver = /usr/local/lib/libodbc.dylib"
found driver /usr/local/lib/libodbc.dylib for [MySQLDriver] in odbcinst.ini
/usr/local/lib/libodbc.dylib is an executable file
"Server" found, not using freetds.conf
Server is "127.0.0.1"
looking up hostname for ip address 127.0.0.1

Configuration looks OK. Connection details:

               DSN: mysql-local
          odbc.ini: /Users/homer/.odbc.ini
            Driver: /usr/local/lib/libodbc.dylib
   Server hostname: localhost
           Address: 127.0.0.1

Attempting connection as testuser ...

  • isql mysql-local testuser testpass -v
    [IM004][unixODBC][Driver Manager]Driver's SQLAllocHandle on SQL_HANDLE_HENV failed
    [ISQL]ERROR: Could not SQLConnect
    sed: /tmp/osql.dump.44362: No such file or directory
我尝试的每件事都会归结为同一个错误:

[IM004][unixODBC][Driver Manager]Driver's SQLAllocHandle on SQL_HANDLE_HENV failed

为了更好的衡量,这是来自 `isql mysql-local testuser testpass` :

[ODBC][54953][1538867223.117217][__handles.c][460]
Exit:[SQL_SUCCESS]
Environment = 0x7f9829010400
[ODBC][54953][1538867223.117416][SQLAllocHandle.c][377]
Entry:
Handle Type = 2
Input Handle = 0x7f9829010400
[ODBC][54953][1538867223.117521][SQLAllocHandle.c][493]
Exit:[SQL_SUCCESS]
Output Handle = 0x7f982903e800
[ODBC][54953][1538867223.117601][SQLConnect.c][3721]
Entry:
Connection = 0x7f982903e800
Server Name = [mysql-local][length = 11 (SQL_NTS)]
User Name = [testuser][length = 8 (SQL_NTS)]
Authentication = [********][length = 8 (SQL_NTS)]
UNICODE Using encoding ASCII 'UTF-8' and UNICODE 'UCS-2-INTERNAL'

[ODBC][54953][1538867223.126854][SQLConnect.c][1380]Error: IM004
[ODBC][54953][1538867223.127046][SQLFreeHandle.c][290]
Entry:
Handle Type = 2
Input Handle = 0x7f982903e800
[ODBC][54953][1538867223.127191][SQLFreeHandle.c][339]
Exit:[SQL_SUCCESS]
[ODBC][54953][1538867223.127276][SQLFreeHandle.c][220]
Entry:
Handle Type = 1
Input Handle = 0x7f9829010400

笔记:
我在其他地方也看到过同样的错误,需要odbc中介连接到其他数据库(例如sqlserver)。在这些情况下提出的解决方案似乎不适用于mysql连接。
我希望能与此建立联系 `linuxodbc` ,因为这是在r studio ide中实现最大sqlintegration所需的工具。
在linux上,我发现unixodbc工作得很好。
非常感谢任何能给我指出正确方向的人。

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题