Trying to export the data from mysql to csv will end up in creating the csv file in the mysql data directory (/var/lib/mysql). Use this method to covert the individual tables from mysql to CSV format
$mysql -u <username> -h <hostname> <databasename> -p -B -e "select * from table;" | sed 's/\t/","/g;s/^/"/;s/$/"/;s/\n//g' > test.csv
Note: The whole command above must essentially be in a single line
No comments:
Post a Comment