From:       To:      
Home > Documentation > SQL Server to MySQL

Command line version of SQL Server to MySQL converter

To perform batch conversion or call conversion procedure from an automation script you can use console version of MSSQL-to-MySQL called M2SAGENT.EXE. Find this file in MSSQL-to-MySQL installation folder. You can either run this tool directly from command line or call it from any script as well. The program supports the following command-line options:

--as_dbo   connect to MS SQL server as database owner
--charset=...   MySQL character set
--dest=...   MySQL database or dump file name
--dump   convert MS SQL database into 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 an existing MySQL database (0 - overwrite the entire database, 1 - overwrite existing tables only, 2 - skip existing tables, 3 - merge, 4 - synchronize)
--mssqlh=...   MS SQL server IP address or network name
--mssqlu=...   MS SQL user name
--mssqlp=...   MS SQL user password
--mysqlh=...   MySQL server IP address or network name
--mysqlu=...   MySQL user name
--mysqlp=...   MySQL user password
--owned   convert tables owned by the user only
--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=...   MS SQL database name
--tab_def   convert table definitions only
--tab_file=...   name of the file containing table names to convert (one table name per line)
--views   convert MS SQL views into MySQL

In the following example the program converts local MS SQL database "db1" into MySQL database "db1 from mssql" on the remote MySQL server "mysqlhost" using table names file "c:\tabfile1.txt":

M2SAGENT.EXE --src=db1 --dest="db1 from mssql" --mysqlh=mysqlhost --mysqlu=administrator 
--mysqlp=the_passsword --tab_file=c:\tabfile1.txt

Table names file should be formatted as follows:

Table_1
Table_2
...
Table_N

 

Notes:

  1. If you specified a profile, there is no need to specify any other parameters
  2. You can omit 'mssqlh' or 'mysqlh' to connect local database server
  3. You can omit 'mssqlu' and 'mssqlp' parameters to connect to MS SQL server using Windows authentication
  4. It is necessary to specify 'port' parameter only if it differs from the default MySQL port 3306
  5. If you omit 'tab_file' parameter, all database tables will be converted
  6. If you omit 'mode' parameter, default mode 'overwrite the entire database' will be used
  7. Command line parameters that contain spaces should be enclosed in quotes (for example --dest="my database")

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.

Have any questions? Contact us