#!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
Server Fault is a question and answer site for system and network administrators. It only takes a minute to sign up.
Sign up to join this communityMysql documentation is pretty clean:
#!bin/bash
query="update table_name set colume ='i' where column_name is NOT NUll"
mysql -u username -ppassword mysql -e "$query";
-e
option allows to send an arbitrary query to the mysql server.
Notice that there is no space between -p
and password
- that is an intentional syntax of mysql
CLI
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.
Query="..."
...$query;
Your problem is here...