0

Is there a simple way to output a CSV from MySQL that can be read by all users?

The issue is as follows. On macosx by default the user is _msyql who is a member of the wheel group. Also by default the INTO command will create a file with read permissions for the wheel group only. Since adding a user to the wheel group is not good, this would seem to imply there is no good simple way to make use of INTO.

Peter Cotton
  • 391
  • 2
  • 7

1 Answers1

1

It really depends on your definition of "simple".

Instead of using the select into clause (which causes the behavior you observed), you can direct mysql client output to stdout and do the csv creation yourself:

mysql mydatabase -B -e 'select * from mytable' | sed 's/\t/,/g' > output.csv

There's more info covering sed processing corner cases here.

lemon
  • 14,875
  • 6
  • 18
  • 38
Eric Shieh
  • 697
  • 5
  • 11