2

I have written a script to extract the contents of a table into a textfile. this is my code

#!/bin/bash

mysql -uroot -ppasswd database select * from table>textfile.txt

i have changed permissions on the file and when i run it using ./myscript it creates textfile.txt but loads into it the mysql manual.How can i achieve my desired result

1 Answer 1

4

It shows you the manual because it's the wrong syntax. Try this:

mysql -uroot -ppasswd database -e "select * from table" >textfile.txt

From the manual:

-e, --execute=name  Execute command and quit. (Disables --force and history file.)

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .