Shell-一行查询 [英] Shell - one line query
本文介绍了Shell-一行查询的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我需要使用bash在一行中执行mysql查询.
I need to execute a mysql query in one line using bash.
应该是这样的:
mysql database --user='root' --password='my-password' < query.file
但不是< query.file
,而是要使用这样的原始查询:
But instead of the < query.file
it would like to use a raw query like this:
mysql database --user='root' --password='my-password' < UPDATE `database` SET `field1` = '1' WHERE `id` = 1111;
有可能吗?
推荐答案
您尝试过
mysql -u root -pmy_password -D DATABASENAME -e "UPDATE `database` SET `field1` = '1' WHERE `id` = 1111;" > output.txt
(> output.txt
部分可以忽略,但是,通过查看文件来查看执行的语句返回的内容将很有用.)
(the > output.txt
part can be ignored but, it will be useful to see what was returned by the statement executed by looking at the file.)
这篇关于Shell-一行查询的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文