cron job file:
46 13 * * * root /home/tmp/test_mysql.sh
script:
execute_query(){ query="$1" res=`mysql --skip-column-names -e "$query"` echo "$res" } res=`execute_query "show databases"` echo $res
error I got from when cron job executes the script successfully:
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)
I can execute the script successfully from command line as root because the login credential for mysql are saved in /root/.my.cnf what's wrong? is cronjob somehow not reading /root/.my.cnf?