Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Export csv from mysql by query
mysql -u USER -p -B DB < QUERY.sql | sed 's/"/\\"/g' | sed "s/'/\'/;s/\t/\",\"/g;s/^/\"/;s/$/\"/;s/\"NULL\"/NULL/g;s/\n//g" >RESULT.csv
Copy link

mirkoperillo commented Dec 2, 2020

This script is an improvement of the original found in a stackoverflow answer
here the original source:

The original answer is licensed under CC BY-SA 3.0
This improved script is under the same license

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment