mysql連線oracle補償方案—odbc驅動
環境:
MYSQL伺服器:mysql 5.1.55 64位
ORACLE伺服器 : oracle 10g 64位
安裝
1.安裝資料來源驅動(ODBC)64位
Connector/ODBC 5.3.14 :
2.開啟 ODBC 資料來源:
開啟後選擇系統DSN:
選擇:ANSI Driver
配置完成後點選ok就行
3.在cmd 驗證一下,輸入dg4odbc
配置oracle
1.透明閘道器配置
找到你的oracle的安裝目錄的initdg4odbc.ora檔案,然後複製一份,命名規則是:init+sid.ora,所以就是initmysqlodbc.ora;
initmysqlodbc.ora(斜體加粗部分)
HS_FDS_CONNECT_INFO = mysqlodbc
HS_FDS_TRACE_LEVEL = off
2.listener.ora配置(斜體加粗部分)
SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC =
(SID_NAME = orcl)
(GLOBAL_DBNAME = orcl)
(ORACLE_HOME = F:\product\11.2.0\dbhome_1)
(ENVS = "EXTPROC_DLLS=ONLY:F:\product\11.2.0\dbhome_1\bin\oraclr11.dll"))
(SID_DESC =
(GLOBAL_DBNAME = orcl)
(ORACLE_HOME = F:\product\11.2.0\dbhome_1)
(SID_NAME = orcl)
)
(SID_DESC =
(SID_NAME = mysqlodbc)
(ORACLE_HOME = F:\product\11.2.0\dbhome_1)
(PROGRAM = dg4odbc)
)
)
3.sqlnet.ora(斜體加粗部分)
SQLNET.AUTHENTICATION_SERVICES= (NONE
)NAMES.DIRECTORY_PATH= (TNSNAMES, EZCONNECT)
4.tnsnames.ora(斜體加粗部分)
mysqlodbc =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = localhost)(PORT = 1521))
)
(CONNECT_DATA =
(SERVICE_NAME = mysqlodbc)
)
(HS = OK)
)
5.資料庫測試
在資料執行以下語句
create public database link mysqlodbc connect to "admin" identified by "admin" using 'mysqlodbc';
admin/admin為mysql資料庫賬號密碼
執行查操作
SELECT * FROM tb_hisdata@mysqlodbc
SELECT * FROM tb_hisdata@mysqlodbc where "sfvalue"!='0';
注意!注意where子句列名加",不加我電腦上報列名不存在!
錯誤1
Connection Failed
[MySQL][ODBC 5.3(w) Driver]Access denied for user 'root'@'192.168.18.155' (using password: YES):
新建個使用者 admin
附上所有許可權
錯誤2
Connection Failed
[MySQL][ODBC 5.3(w) Driver]Unknown character set: 'utf8mb4':
編碼錯誤,選擇ANSI Driver