0

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?

Community
  • 1
  • 1
tapaljor
  • 237
  • 1
  • 6
  • 21

1 Answers1

1

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.

middlestump
  • 1,035
  • 8
  • 22
  • I think CSV is only option I am left. When I try that it says access denied. Should run on commandline or inside mysql? – tapaljor Aug 10 '16 at 08:53
  • can do with in the console but you don't have the select into outfile permission (or so it seems) – middlestump Aug 10 '16 at 08:57