3
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

MySQLの結果を簡単にcsvにする方法

Last updated at Posted at 2013-11-14

以下のようにやればカンマ区切りで結果がファイルに吐出されます。

mysql -u user_name -p -h host_name db_name -e "select * from table_name;" | sed 's/\t/","/g;s/^/"/;s/$/"/;s/\n//g' | sed '1d' > /var/tmp/table_name.csv
3
3
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?