Reputation: 257
I have been looking for solution to export table with specific fields/columns. I am using Ubuntu commandline to do that. Luckily MySQL dump by query help me achieve my goal with
mysql -e "select * from myTable" -u myuser -pxxxxxxxx mydatabase > mydumpfile.txt
But, I am getting plain text file. I want to get file dumped as SQL format. So can I get dumped file with mydumpfile.sql instead of mydumpfile.txt?
Upvotes: 0
Views: 254
Reputation: 1055
If you want full insert statements you have to use mysqldump
. if you want comma separated (CSV) you have to use SELECT INTO OUTFILE
from the mysql client.
mysql -e does a query on the database and shows result in the console. Your redirect '>' at the end means that display get's saved to a file. That saved file is not very usefull for programming work. It's only for humans.
Upvotes: 1