Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/macos/10.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Mysql IM004使用unixodbc连接到数据库(macos)时出错_Mysql_Macos_Rstudio_Unixodbc - Fatal编程技术网

Mysql IM004使用unixodbc连接到数据库(macos)时出错

Mysql IM004使用unixodbc连接到数据库(macos)时出错,mysql,macos,rstudio,unixodbc,Mysql,Macos,Rstudio,Unixodbc,在我的Mac电脑上,我试图用unixodbc(自制的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

在我的Mac电脑上,我试图用unixodbc(自制的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/ceral/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告诉我它是用来连接到sqlserver的。(可能是Brew的unixodbc附带的?)我可以用它来验证
.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中介连接到其他数据库(例如SQL Server)。在这些情况下提出的解决方案似乎不适用于MySQL连接
  • 我希望能与
    linuxodbc
    建立连接,因为据说这是在系统中实现最大SQLintegration所需的工具
  • 在Linux上,我发现unixodbc工作得很好
非常感谢所有能为我指明正确方向的人