Jump to content

mysql dump - cron job

- - - - -

This topic has been archived. This means that you cannot reply to this topic.
3 replies to this topic

#1
zaphe87

zaphe87

    Newbie

  • Members
  • Pip
  • 2 posts
I'm not sure if this is the right category for this, i couldn't see a better titled one..

I am trying to set up a cron job to automatically backup my mysql databases. After viewing many examples and tutorials i finally managed to get beyond the point of it rejecting my command or failing to connect, this is what i had:

With my password/username, etc... ***'d out

nice -n 15 /usr/bin/mysqldump --opt -u *** -p*** ¦ gzip > /home/***/backups/mysqlbackup_`date +\%d\%m\%y`.sql.gz

And i got this response from the automated email:

mysqldump: Got error: 1044: Access denied for user '***r'@'localhost' to database '?' when selecting the database


So i tried adding --all-databases to it, but wasn't sure where to put it, ended up with this:

nice -n 15 /usr/bin/mysqldump --opt -u *** -p*** --all-databases ¦ gzip > /home/***/backups/mysqlbackup_`date +\%d\%m\%y`.sql.gz

But now it doesn't seem to be running, as i'm not getting the email.

Could anyone tell me where i'm going wrong? Thanks.

#2
Guest_Jordan_*

Guest_Jordan_*
  • Guests
Can you login to mysql command using the same username/pass? Just type mysql -u <username> -p

#3
zaphe87

zaphe87

    Newbie

  • Members
  • Pip
  • 2 posts
The username and password are correct, it just don't know where to tell it which databases to dump.

#4
Guest_Jordan_*

Guest_Jordan_*
  • Guests
--all-databases will dump ALL databases. I'm not familiar with the nice command, what does it do? Does running this manually work (not in cron)?

/usr/bin/mysqldump --opt -u *** -p*** --all-databases  > allbackups.sql

?

If you look here: MySQL :: MySQL 5.1 Reference Manual :: 4.5.4 mysqldump — A Database Backup Program
and scroll to the bottom you can find many user contributed mysql dump/backup scripts.