Yikes! Something strange in a cron job.

S. Dale Morrey sdalemorrey at gmail.com
Sat Feb 8 14:59:26 MST 2014

To clarify the command is "mysqldump dbname"
I didn't specify a user because my understanding is that whatever system
user (in this case root) and password doesn't need to be specified as long
as long as the .my.cnf file is resident in their home directory and
contains the correct credentials that the system user wants to be against
the DB.

This works perfectly when I'm logged in as root, but for some reason
mysqldump doesn't want to read the my.cnf file from from /root when run in
This makes me wonder if I need to specify HOME as in "export HOME=/root"
I'm going to give that a shot and see if it solves the problem.

On Sat, Feb 8, 2014 at 2:49 PM, Jonathan Duncan <jonathan at bluesunhosting.com
> wrote:

> On Sat, Feb 8, 2014 at 12:10 PM, S. Dale Morrey <sdalemorrey at gmail.com
> >wrote:
> >
> > I added a MAILTO in crontab so I get a "crons eye view" of why I'm not
> > getting my backup file and I get this error.
> >
> > mysqldump: Got error: 1045: Access denied for user 'root'@'localhost'
> > (using password: NO) when trying to connect
> >
> > What's strange about this error is that it's coming from a script called
> by
> > crontab, that runs perfectly fine as root.
> >
> > That is interesting. The error is a mysql error. The 'root' user is the
> mysql user. It is complaining that there is no password being specified
> when invoking the mysqldump command. Is the script using environment
> variables to supply the password? If so, I am not sure what the behavior is
> for cron in relation to loading user config files (eg bashrc and profile).
> /*
> PLUG: http://plug.org, #utah on irc.freenode.net
> Unsubscribe: http://plug.org/mailman/options/plug
> Don't fear the penguin.
> */

More information about the PLUG mailing list