Command for exporting data from MySQL to a csv file

Source: Internet
Author: User
1. MySQL export local database data to local file mysql-Aservice_db-hyour_host-utest-ptestmysqlgt; select * fromt_1_wherecr

1. MySQL exports local database data to the local file mysql-A service_db-h your_host-utest-ptestmysqlgt; select * from t_apps where cr

1. MySQL exports local database data to a local file

Mysql-A service_db-h your_host-utest-ptest

Mysql> select * from t_apps where created> '2017-07-02 00:00:00 'into outfile/tmp/example .csv

2. MySQL exports 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'> pai.csv

(Sed can be omitted, especially when processing data containing Chinese characters)

3. Use mysqldump to export remote or local data to a local file

Mysqldump-h your_host-utest-ptest-w "id <300" service_db t_apps> tt. SQL

If only-t or -- no-create-info is added to the imported data;

If you add-d or -- no-data;

4. mysqldump cannot specify the exported column. The work und is as follows:

Mysql-u USERNAME -- password = PASSWORD -- database = DATABASE -- execute = 'select 'field', 'field' FROM 'table' LIMIT 0, 100'-X> file.csv

,

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.