0
#!bin/bash
Query="update table_name set colume ='i' where column_name is NOT NUll"

mysql -u username -p password mysql  <<EOF
$query;
EOF

The above script is not working

| improve this question | | | | |
  • 1
    What error message do you get when executing the script? – Khaled May 4 '15 at 7:47
  • 1
    Query="..." ... $query; Your problem is here... – moebius_eye May 4 '15 at 10:15
5

Mysql documentation is pretty clean:

#!bin/bash
query="update table_name set colume ='i' where column_name is NOT NUll"
mysql -u username -p password mysql -e "$query";

-e option allows to send an arbitrary query to the mysql server.

| improve this answer | | | | |
5

The above script is not working because the shell syntax is case-sensitive, and you used Query to define the variable, then query to expand it.

Otherwise, see @Kondybas 's answer for the proper way to do this.

| improve this answer | | | | |

Not the answer you're looking for? Browse other questions tagged or ask your own question.