Formatting code for MysqlCSVExport
{{parent page="MySQL"}}
===Export tables to CSV===
One will find the outout file under /var/lib/mysql/database_name/table_name.csv
%%
select * from table_name into outfile 'table_name.csv' fields terminated by ',' enclosed by '"';
%%
===Import tables from CSV===
Use mysqlimport. Note that table name is read by removing the .txt extension from the import text file.
%%
mysqlimport --fields-terminated-by=',' --fields-enclosed-by='"' db_name table_name.txt
%%
===Export tables to CSV===
One will find the outout file under /var/lib/mysql/database_name/table_name.csv
%%
select * from table_name into outfile 'table_name.csv' fields terminated by ',' enclosed by '"';
%%
===Import tables from CSV===
Use mysqlimport. Note that table name is read by removing the .txt extension from the import text file.
%%
mysqlimport --fields-terminated-by=',' --fields-enclosed-by='"' db_name table_name.txt
%%