From:       To:      
Home > Documentation > DB2 to MySQL

Command line version of DB2 to MySQL converter

To perform batch conversion or call the tool from an automation script you can use console version of DB2 to MySQL converter called B2SAGENT.EXE. Find this program in the installation folder. B2SAGENT.EXE supports the following parameters:

--charset=...   MySQL character set
--db2pswd=...   DB2 user password
--db2schema=...   DB2 schema name
--db2user=...   DB2 user name
--dest=...   MySQL database name
--dump   convert DB2 database into MySQL dump file
--engine=...   MySQL storage engine (MyISAM, MEMORY, InnoDB, BerkeleyDB, ARCHIVE, FEDERATED, etc). Please refer to MySQL documentation for the further information.
--help   display help message and exit
--logfile=...   path to the logfile where execution traces will be written
--mode=...   how to process existing MySQL database (0 - overwrite the entire database, 1 - overwrite existing tables only, 2 - skip existing tables, 3 - merge)
--mysqlh=...   MySQL server IP address or network name
--mysqlu=...   MySQL user name
--mysqlp=...   MySQL user password
--port=...   MySQL port
--profile=...   path to the file to load conversion settings from
--silent   use this option to disable program output
--skip_idx   skip converting indexes
--src=...   DB2 database name
--tab_def   convert table definitions only
--tab_file=...   file containing table names to convert (one table name per line)

In the following example the program converts all tables from tablespace "SYSTOOLS" of DB2 database "db 1" into local MySQL database "db_mysql":

B2SAGENT.EXE --src="db 1" --db2schema=SYSTOOLS --db2user=scott --db2pswd=tiger 
--dest="db_mysql" --mysqlh=mysqlhost --mysqlu=administrator --mysqlp=the_passsword

Notes:

MySQL character sets

This parameter specifies correct encoding of text values in the destination MySQL database. It can have one of the following values:

value   Description     value   Description
big5   Big5 Traditional Chinese     dec8   DEC West European
cp850   DOS West European     hp8   HP West European
koi8r   KOI8-R Relcom Russian     latin1   cp1252 West European
latin2   ISO 8859-2 Central European     swe7   7bit Swedish
ascii   US ASCII     ujis   EUC-JP Japanese
sjis   Shift-JIS Japanese     hebrew   ISO 8859-8 Hebrew
tis620   TIS620 Thai     euckr   EUC-KR Korean
koi8u   KOI8-U Ukrainian     gb2312   GB2312 Simplified Chinese
greek   ISO 8859-7 Greek     cp1250   Windows Central European
gbk   GBK Simplified Chinese     latin5   ISO 8859-9 Turkish
armscii8   ARMSCII-8 Armenian     utf8   UTF-8 Unicode
ucs2   UCS-2 Unicode     cp866   DOS Russian
keybcs2   DOS Kamenicky Czech-Slovak     macce   Mac Central European
macroman   Mac West European     cp852   DOS Central European
latin7   ISO 8859-13 Baltic     cp1251   Windows Cyrillic
cp1256   Windows Arabic     cp1257   Windows Baltic
binary   Binary pseudo charset     geostd8   GEOSTD8 Georgian
cp932   SJIS for Windows Japanese     eucjpms   UJIS for Windows Japanese

Please refer to MySQL documentation to better understand the concept of character sets and collations.