Shell - one line query

前端 未结 6 1533
天命终不由人
天命终不由人 2021-02-07 02:01

I need to execute a mysql query in one line using bash.

It should be something like this:

mysql database --user=\'root\' --password=\'my-password\' <          


        
6条回答
  •  悲哀的现实
    2021-02-07 02:13

    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.)

提交回复
热议问题