Commonly we use the “mysqldump” tool to generate or backup data. But the standard output of the utility is SQL, or bunch of SQL statements starting from the “CREATE TABLE …” .. to the “INSERT INTO …”
Most of the times we just need a simple CSV or a tab separated data dump. And then we start searching for options, phpMyAdmin.
To get a CSV dump, the mysqldump utility needs some parameters.
mysqldump -T /folder_path –fields-terminated-by=’,’ –fields-enclosed-by='”‘ –lines-terminated-by=’\r\n’ -u root -p database_name table_name
Note: I’m unable to show double hyphen before fields-terminated-by
It should be something like this.
The above command will save 2 files “tablename.sql” and “tablename.txt”.
The tablename.sql will have a CREATE TABLE script while the tablename.txt will contain a comma separated data dump of the table. Both the files will be create in the folder “/folder_path”
A similar command is used to get a TAB separated dump
mysqldump -T /folder_path -u root -p database_name table_name
While using this command more than one table can be dumped, just list all the tables separated by a space