Shell - one line query Shell - one line query mysql mysql

Shell - one line query


Did you try

 mysql -u root -pmy_password -D DATABASENAME -e "UPDATE `database` SET `field1` = '1' WHERE `id` = 1111;" > 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.)


Use the -e option:

$ mysql -e "UPDATE ..."


Use echo and a pipe:

echo "UPDATE `database` SET `field1` = '1' WHERE `id` = 1111;" | mysql database --user='root' --password='my-password'