Arun Killu
Arun Killu

Reputation: 14263

Output sql output from bash

I was using OUTFILE command but due to permission issue and security risk I thought of dumping the output of shell to file but has got some error . What I have tried

#This is a simple shell to connect to mysql db
cat  mysql -h "localhost" -u  "XXXXXXX" "-pXXXXXX"  standard_new2 << EOF
select * from cnhdatad limit 10;
EOF  ./sample2.txt

Upvotes: 2

Views: 122

Answers (1)

anubhava
anubhava

Reputation: 786091

That's incorrect output redirection syntax for heredoc.

Try this command:

mysql -h "localhost" -u  "XXXXXXX" "-pXXXXXX"  standard_new2 << EOF > ./sample2.txt
select * from cnhdatad limit 10;
EOF

Upvotes: 5

Related Questions