Kurinchi Blogger Scribbles …


Posts Tagged ‘mysql data import’

Feb 12
2009

MySql Tip for Beginners – Export records to .csv from Command line

Last updated: February 12th, 2009

Exporting a .CSV file based on user requirement is very easy in MySQL.

A simple query could generate your desired output as .CSV file. Let’s see what that command is

[root@localhost]$ mysql -u [username] -p [password]

[root@localhost]$ use [my_database]

[root@localhost]$ SELECT * INTO OUTFILE ‘/userinfo.csv’ FIELDS TERMINATED BY ‘,’ OPTIONALLY ENCLOSED BY ‘”" ESCAPED BY ‘\\’ LINES TERMINATED BY ‘\n’ FROM Table_Users;

Voila! You have your desired results in as a .csv file.

In the next article, we will discuss on how we can import data from .csv file back into database.


Valid HTML 4.01 Strict  Valid HTML 4.01 Strict