Q:

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.
#!/bin/bash
mysql -uuser -hremotehost -pmypassword -e "update my_table set what_time = NOW()";

Is there a way to put mypassword in my local /etc/my.cnf file or something else to keep it out of open text command line?
Assume my remotehost doesn't accept no password for mysql.

A:

As written over at dba it is possible to configure your my.cnf file as the following:
[clienthost1]   # Note: client + host1
user=user
password=mypassword
host=remotehost

and run it as:
mysql --defaults-group-suffix=host1

Kudus to Derek Downey answer at DBA

