2016-09-28 6 views
0

Mac (Mac OS X 10.11.2)의 R에서 MySQL 데이터베이스에 액세스하는 데 문제가 있습니다. 다음 코드 :Mac OS X에서 R의 MySQL 데이터베이스에 액세스

library("RODBC") 
mycom <- odbcConnect("wsn_mysql_5", uid="root", pwd="*****") 

이 오류를 제공합니다 :

1: In RODBC::odbcDriverConnect("DSN=wsn_mysql_5;UID=root;PWD=****") : 
[RODBC] ERROR: state 00000, code 15509574, message 
[iODBC][DriverManager]dlopen(/usr/local/lib/libmyodbc5a.so, 
6): no suitable image found. Did find: 
/usr/local/lib/libmyodbc5a.so: mach-o, but wrong architecture 
2: In RODBC::odbcDriverConnect("DSN=wsn_mysql_5;UID=root;PWD=****") : 
[RODBC] ERROR: state IM003, code 15509574, message 
[iODBC][Driver Manager]Specified driver could not be loaded 

내가 지금까지 시도하는 것 :

  1. 나는이 iODBC 드라이버 관리자 3.52.12를 설치했습니다.
  2. MySQL 커넥터 odbc-5.3.6-osx10.11-x86-64bit를 설치하고 DSN (server = localhost, user = root, password = *****, database = wsn_db)을 만들었습니다. 이 iODBC 관리자에 테스트 때이 오류가 발생했다

:

[iODBC][Driver manager]dlopen(/usr/local/lib/libmyodbc5w.so, 6): no suitable image found. 
Did find: /usr/local/lib/libmyodbc5w.so: mach -o, but wrong architecture. 

How to add ODBC to MAMP on OSX

날 즉 생각하는 32 비트 대 64 비트 문제가 있었다했다.

  1. 그래서 최근에 발견 된 32 비트 버전 인 odbc-5.2.7-osx10.7-x86-32bit MySQL 커넥터를 설치했습니다. 나는이 iODBC 관리자와이를 테스트 할 때 작동하는 것 같다,하지만 난이 유형의 오류에 대한 다음과 같은

이 iODBC의 질문 말한다 R.의 코드를하려고 할 때 나는 처음에 언급 한 오류가 발생합니다 :

[iODBC] [Driver Manager]Specified driver could not be loaded

There are a few reasons why this could occur, and thinking through the architecture helps. Your application has loaded libiodbc successfully, and it has found an odbc.ini file (or equivalent through the ODBCINI environment variable), and it has found a DSN within that odbc.ini that matches the name requested in your connection.

However, the driver manager has had problems loading the library specified in the `Driver=' line of that DSN definition. Either it doesn't exist, or its permissions are insufficient to allow your application to load it (it must be readable and executable, and the directories leading down to it must be executable), or maybe the file is not a dynamic library - it could be a static library (a *.a file except on AIX) or is otherwise corrupted. These are all things to check, or you may be best off reinstalling the driver if all the permissions check out.

  1. 그래서 권한을 확인했지만 정확했습니다.
  2. 또한 드라이버를 다시 설치했지만 아무 것도 변경하지 않았습니다.

  3. this을 읽은 후 odbc.ini와 obdcinst.ini를 확인했습니다.

    [ODBC Drivers] 
    MySQL ODBC 5.2 ANSI Driver=Installed 
    MySQL ODBC 5.2 Unicode Driver=Installed 
    
    [ODBC Connection Pooling] 
    PerfMon=0 
    Retry Wait= 
    
    [MySQL ODBC 5.2 ANSI Driver] 
    Driver = /usr/local/lib/libmyodbc5a.so 
    Description = mySQL driver 
    Threading = 0 
    
    [MySQL ODBC 5.2 Unicode Driver] 
    Driver = /usr/local/lib/libmyodbc5w.so 
    Description = mySQL driver 
    Threading = 0 
    

    [ODBC Data Sources] 
    wsn_mysql_7 = wsn_mysql_7 
    
    [ODBC] 
    TraceLibrary= 
    
    [wsn_mysql_7] 
    Driver = /usr/local/lib/libmyodbc5w.so 
    DATABASE = wsn_db 
    DESCRIPTION = DSN for wsn_db in R 
    SERVER = localhost 
    UID = root 
    PASSWORD = ***** 
    

    및 ODBCINST.INI 그러나 아무것도 변경하는 것 같지 않았어요 :

나는에 ODBC.INI 변경되었습니다.

  1. 또한 this question을 기반으로하는 다른 RODBC 코드를 사용해 보았습니다.

    mycom <- odbcDriverConnect("Provider=MSDASQL;Driver={MySQL ODBC 5.2 UNICODE Driver}; 
    Server=localhost;database=wsn_db;Uid=root;Pwd=*****;Option=3") 
    

나는 다음에 무엇을 확실하지 않다? R에서 mySQL 데이터에 액세스하는 완전히 다른 방법조차도 도움이 될 것입니다.

+2

[RMySQL] (https://cran.r-project.org/package=RMySQL)을 사용해 보셨습니까? – ytk

+0

MAMP를 사용하여 Mac에서 RMySQL을 사용하여 성공했습니다. –

+0

RMySQL은 ODCB 드라이버가 필요합니까? 왜냐하면 이것이 문제의 원인이라고 생각하기 때문입니다. –

답변

1

마지막으로 unixODBC를 사용하고 64 비트 ANSI 커넥터를 사용하여 작업 구성을 관리 할 수있었습니다.당신이 RODBC와 MySQL 데이터베이스에 연결하려는 경우 내가 추천 :

  1. 가 인 unixODBC 및 RODBC
  2. 최신 MySQL ODBC connector 설치 설치 this tutorial를 따르십시오. 나는 mysql-connector-odbc-5.3.6-osx10.11-x86-64bit를 설치했다. 설치 프로그램이 작동하지 않아 tar에서 설치해야했습니다. 지침은 here입니다.
  3. ODBC 관리자를 사용하여 DSN을 구성했지만 [Hiltmon 's tutorial]의 지침이 잘 작동 할 수도 있습니다.
  4. 내가 먼저 유니 코드 드라이버를 사용하지만, 다음과 같은 오류 있어요 :

    Warning messages: 
    1: In RODBC::odbcDriverConnect("DSN=wsn_db_dsn;UID=root;PWD=****") :  
    [RODBC] ERROR: state H, code 0, message [unixODBC][ 
    2: In RODBC::odbcDriverConnect("DSN=wsn_db_dsn;UID=root;PWD=****") : 
    ODBC connection failed 
    

    내가 RODBC error - ODBC connection failed - can't connect to MySQL with my mac (mavericks)에서 제안으로 ANSI 드라이버를 선택하여 수정합니다.

시간이 절약되기를 바랍니다.