Dump a mysql database to a plaintext (CSV) backup from the command line

前端 未结 10 1076
广开言路
广开言路 2020-11-28 19:26

I\'d like to avoid mysqldump since that outputs in a form that is only convenient for mysql to read. CSV seems more universal (one file per table is fine). But if there ar

10条回答
  •  北荒
    北荒 (楼主)
    2020-11-28 19:38

    In MySQL itself, you can specify CSV output like:

    SELECT order_id,product_name,qty
    FROM orders
    INTO OUTFILE '/tmp/orders.csv'
    FIELDS TERMINATED BY ','
    ENCLOSED BY '"'
    LINES TERMINATED BY '\n'
    

    From http://www.tech-recipes.com/rx/1475/save-mysql-query-results-into-a-text-or-csv-file/

提交回复
热议问题