468,471 Members | 1,596 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,471 developers. It's quick & easy.

how can i redirect Mysql table output to file in Linux?

Hi Bytes, in Linux , is it possible to redirect Mysql table output to a file in Linux.

i tried it, shows error , but output has displayed in linux prompt when no redirection of file has given(say select * from tablename) but when i am trying redirect output to file in Linux it shows error? can you tell me suggestion for this issue.

code i used :
<code>
#!bin/sh
password=xyzbac
mysql -u root -p$password -h 192.168.1.8 << y
use sys;
select memory from sysprofile >> newf1
quit
y

</code>

got error:

ERROR 1064 (42000) at line 2: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '>> newf1
quit' at line 1
Jan 7 '09 #1
2 6373
micmast
144 100+
What happens if you try this:

#!bin/sh
password=xyzbac
mysql -u root -p$password -h 192.168.1.8 << y
use sys;
echo `select memory from sysprofile` >> newf1
quit
y
Jan 7 '09 #2
Error i got after changes that you have suggested:

tesst1.sh: command substitution: line 1: syntax error near unexpected token `from'
tesst1.sh: command substitution: line 1: `select memory from sysprofile'
ERROR 1064 (42000) at line 2: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'echo >> newf1
quit
y' at line 1
Jan 7 '09 #3

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

reply views Thread by Lenz Grimmer | last post: by
reply views Thread by Mike Chirico | last post: by
6 posts views Thread by cmk128 | last post: by
1 post views Thread by PowerLifter1450 | last post: by
Atli
6 posts views Thread by Atli | last post: by
reply views Thread by NPC403 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.