Change output format for MySQL command line results to CSV

前端 未结 7 2068
囚心锁ツ
囚心锁ツ 2020-12-05 03:54

I want to get headerless CSV data from the output of a query to MySQL on the command line. I\'m running this query on a different machine from the MySQL server, so all those

7条回答
  •  醉话见心
    2020-12-05 04:34

    mysqldump utility can help you, basically with --tab option it's a wrapped for SELECT INTO OUTFILE statement.

    Example:

    mysqldump -u root -p --tab=/tmp world Country --fields-enclosed-by='"' --fields-terminated-by="," --lines-terminated-by="\n" --no-create-info
    

    This will create csv formatted file /tmp/Country.txt

提交回复
热议问题