mysqldump not available from cron

Web hosting discussion, programming, and shared and dedicated servers.
7 posts Page 1 of 1
by sc4arc » Wed Sep 21, 2011 10:57 am
Hi All;

I have a script that generates nightly backups with mysqldump. It's run fine with MySQL4 but this week we updated to MySQL5.5 and now I get an error, "mysqldump: Got error: 1251: Client does not support authentication protocol requested by server; consider upgrading MySQL client when trying to connect"

Code: Select all

#!/bin/sh
#
umask 077

DBNAME=sc4arc_wp55
DBPWRD=<password>
DBHOST=sc4arc-wp55.db.sonic.net
DBUSER=${DBNAME}-all
BACKUPDIR=${HOME}/Backup

BACKUPFILE=${BACKUPDIR}/Backup-DB55-`date +%y%m%d`.sql
if [ -r ${BACKUPFILE} ]
then
  echo "File ${BACKUPFILE} already exists."
  exit 1
fi

mysqldump -h ${DBHOST} -u ${DBUSER} -p${DBPWRD} ${DBNAME} > ${BACKUPFILE}

exit 0
The script runs fine when I run it at the command prompt (that is, as user "sc4arc") but I guess that mysqldump doesn't like user "nobody" knowing the secret password. Any suggestions on how to make this work?

Thanks!

Peter
by augie » Wed Sep 21, 2011 5:29 pm
Try giving "mysqldump" the full path ( /usr/local/bin/mysqldump ), it may not be in the PATH when the cron executes.
by sc4arc » Wed Sep 21, 2011 10:12 pm
I'll try it, but I suspect that it was in some path, since the error message: "mysqldump: Got error: 1251: Client does not support authentication protocol requested by server; consider upgrading MySQL client when trying to connect" looks like it came from mysqldump. It's possible that there's more than one present...

If there's a better way to do this, I'm interested to learn how.
by sc4arc » Thu Sep 22, 2011 8:21 am
Nothing succeeds like success. Cron ran the script correctly this morning, using the full path.

Thanks, Augie! I'll watch for that in the future when I'm scripting.
by bobrk » Thu Sep 22, 2011 10:09 am
Yes, that shows that it was probably running the "wrong" mysqldump when you got the error message. ;)
by sc4arc » Thu Sep 22, 2011 12:00 pm
And the old version only accidentally ran correctly because of a series of coincidences. It was a fault waiting to happen... :oops:
by williamt » Thu Sep 22, 2011 2:49 pm
/usr/bin/mysqldump is what you were running at first which is from version 3.23
/usr/local/bin/mysqldump is from version 5.0.16 which is a little old but understands the new authentication
protocol.
Sr. Systems Administrator @ sonic.net
7 posts Page 1 of 1

Who is online

In total there are 39 users online :: 0 registered, 0 hidden and 39 guests (based on users active over the past 5 minutes)
Most users ever online was 999 on Mon May 10, 2021 1:02 am

Users browsing this forum: No registered users and 39 guests