From:       To:      

MySQL to CSV

[Download
Latest version 1.5 released 02/12/2024

MySQL to CSV converter is a free program to export MySQL, MariaDB or Percona databases into comma separated values (CSV) files. The program has high performance due to low-level connection to MySQL databases and direct writing into CSV files. MySQL to CSV converter does not use ODBC or any other middleware. Command line support allows to script, automate and schedule the conversion process.

Features of MySQL to CSV Converter

  • All versions of MySQL, MariaDB and Percona are supported
  • Fast conversion engine (100MB MySQL database - in less than 5 minutes on average modern system)
  • Option to convert individual tables
  • Option to convert partial data using SELECT-queries
  • Option to select separator: tab, comma or semicolon
  • Option to store conversion settings into profile
  • Command line support
  • Easy-to-use wizard-style interface
  • Full install/uninstall support
  • Unlimited 24/7 support service
  • Freeware

Requirements

  • Supported OS: Windows XP(SP2 or SP3)/2003/Vista/Server 2008/7/8/10, Linux with WINE
  • Necessary privileges to read the source database on MySQL server
    

Download MySQL to CSV converter

Command Line

To perform batch conversion or call the conversion procedure from an automation script you can use console version of MySQL to CSV converter. This is file S2CAGENT.EXE in the installation folder. You can either run this tool directly from command line or call it from any script as well. S2CAGENT.EXE supports the following command-line options:

--dest=...   path to the folder with .csv files
--help   display help message and exit
--host=...   MySQL server IP address or network name
--inc_fnames   include MySQL field names into CSV files
--logfile=...   path to the logfile where execution traces will be written
--mode=...   how to process an existing CSV folder (0 - overwrite the entire folder, 1 - overwrite existing files only, 2 - skip existing files)
--n_delim=...   delimiter symbol to use in the resultinig CSV file (0 - tab, 1 - semicolon, 2 - comma)
--port=...   MySQL port
--profile=...   path to the file to load conversion settings from
--pswd=...   MySQL user password
--silent   use this option to disable program output
--src=...   MySQL database name
--tab_file=...   file containing the list of tables to convert
(one table name per line)
--user=...   MySQL user name

In the following example the program converts MySQL database "db1" on the remote MySQL server "mysqlhost" into .csv files in folder "c:\from mysql" using table names file "c:\tabfile1.txt":

S2CAGENT.EXE --src=db1 --dest="c:\from mysql" --host=mysqlhost --user=administrator 
--pswd=the_passsword --tab_file=c:\tabfile1.txt 

Table names file should be formatted as follows:

Table_1
Table_2
...
Table_N

Notes:

  1. You can omit 'host' parameter to connect local MySQL server
  2. It is necessary to specify 'port' parameter only if it differs from the default MySQL port 3306
  3. If you omit 'tab_file' parameter, all database tables will be converted
  4. Command line parameters that contain spaces should be enclosed in quotes (for example --dest="c:\my database")
  5. If you omit 'mode' parameter, default mode 'overwrite the entire folder' will be used

Download MySQL to CSV converter

Using Queries

Queries give the ability to get part of data for converting into .csv format. The following examples illustrate using queries for particular purposes. Assume there is table "Table1" defined as below:

   Table1(
	ID INT NOT NULL AUTO_INCREMENT, 
	FName VARCHAR(50),
	LName VARCHAR(50), 
	Birthday DATE, 
	Notes TEXT
   );

Example 1. Convert certain records.

    SELECT * FROM Table1 WHERE ID > 1000

Example 2. Choose and rename columns.

    SELECT FName as FirstName, LName as LastName FROM Table1

Example 3. Skip records containing NULL values.

    SELECT * FROM Table1 WHERE Notes IS NOT NULL

Download MySQL to CSV converter