Question & Answer
Question
How to query MySQL Enterprise Edition server by using Db2 Federation through ODBC driver?
Answer
Before You Begin
Enable Federation feature and restart Db2 to make it effective.
$ db2 update dbm cfg using federated YES
Pre-Configuration on linux, unix
1. Make sure the required ODBC drivers are installed correctly.
$ ls sqllib/federation/odbc/lib/FOmysql*.so
2. Make sure the data source is accessible to Federation server.
$ telnet gunlock1.fyre.ibm.com 3306
Trying 9.30.0.167...
Connected to gunloc1.fyre.ibm.com.
3. Create server, user mapping, nickname, and query the nickname.
Note:
3.1 specify the server type "MYSQL" when you create server.
3.2 specify the corresponding codepage server options of character set of remote MySQL DB
$ connect to testdb
$ create server server1 type mysql version 6.0 OPTIONS(host 'gunlock1.fyre.ibm.com', port '3306', dbname 'mysql', codepage '1208')
$ create user mapping for user server server1 options (remote_authid 'root', remote_password 'Passw0rd!')
$ create nickname nk1 for server1."tb1"
$ select * from nk1
col_1
--------------------------
1970-11-23-12.12.12.000000
1999-12-31-12.12.12.000000
2 record(s) selected.
For more information about codepage, refer to What is Db2 federation CODEPAGE server option? , and supported territory codes and code pages
[{"Line of Business":{"code":"","label":""},"Business Unit":{"code":"BU048","label":"IBM Software"},"Product":{"code":"SSCAVPX","label":"Federated Server"},"ARM Category":[],"Platform":[{"code":"PF025","label":"Platform Independent"}],"Version":"All Version(s)"}]
Was this topic helpful?
Document Information
Modified date:
24 January 2022
UID
ibm16431123