Ryan Ryan - 1 year ago 54
Bash Question

How can I execute remote MySQL queries via shell script without putting open text password in my shell script?

I'd rather not execute a query in a shell script with an open text password.

mysql -uuser -hremotehost -pmypassword -e "update my_table set what_time = NOW()";

Is there a way to put
in my local
file or something else to keep it out of open text command line?

Assume my
doesn't accept no password for mysql.

Answer Source

As written over at dba it is possible to configure your my.cnf file as the following:

[clienthost1]   # Note: client + host1

and run it as:

mysql --defaults-group-suffix=host1

Kudus to Derek Downey answer at DBA