1. Export local database data to a local file
Mysql-a service_db-h Your_host-utest-ptest
Mysql> SELECT * from T_apps where created> ' 2012-07-02 00:00:00 ' into outfile/tmp/apps.csv
2. Export remote database data to a local file
Mysql-a service_db-h your_host-utest-ptest-ss-e "select * from T_apps limit 300;" | Sed ' s/\t/', '/g;s/^/'/;s/$/'/;s/\n//g ' > Apps.csv
(The SED section may be slightly, especially when dealing with data containing Chinese characters.) If the content contains Chinese, set names UTF8 can be added before the SELECT statement;)
3. Export remote or local data to a local file using mysqldump
Mysqldump-h your_host-utest-ptest-w "id<300" service_db T_apps > Tt.sql
If only the data is coupled with-t or--no-create-info;
If only the guide structure plus-D or--no-data;
4. Mysqldump cannot specify an exported column, the workaround is as follows:
Mysql-u USERNAME--password=password--database=database--execute= ' SELECT ' field ', ' field ' from ' TABLE ' LIMIT 0, 10000 ' -X > File.csv
MySQL export data to csv file command