Welcome to WebmasterWorld Guest from 54.163.35.238

Forum Moderators: open

Message Too Old, No Replies

Cron job to backup mysql database

what I do wrong?

     

meetzah2

10:01 am on Mar 10, 2007 (gmt 0)

5+ Year Member



Hello,

I use this cron job to backup my database but it doesn't work:

mysqldump -u DBUSER DBNAME -p DBPASSWORD > databasefile.sql

can you tell me what is wrong?
thank you!

dramstore

12:28 pm on Mar 10, 2007 (gmt 0)

10+ Year Member



Try taking out the space after -p and -u so:

-uusername -ppassword

phranque

12:36 pm on Mar 10, 2007 (gmt 0)

WebmasterWorld Administrator phranque is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month



but it doesn't work:

...

can you tell me what is wrong?

in general it's always a good thing to describe your results...

physics

7:29 pm on Mar 10, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



The dbname should come last:

mysqldump -u DBUSER -p DBPASSWORD DBNAME > databasefile.sql

Also, that's not a fully formed crontab line, a full one might look like:


10 0 * * * cd /home/me/backups; /usr/bin/mysqldump --opt -u DBUSER -p DBPASS DBNAME > databasefile.sql

The --opt command is good for backing up databases, from the man file for crontab: "--opt Same as --add-drop-table --add-locks --all --extended-insert --quick --lock-tables".

meetzah2

10:32 am on Mar 12, 2007 (gmt 0)

5+ Year Member



thank you guys,

here is the message i get:

=======================================
Enter password: mysqldump: Got error: 1045: Access denied for user 'USER'@'localhost' (using password: NO) when trying to connect
=======================================

phranque

2:49 pm on Mar 13, 2007 (gmt 0)

WebmasterWorld Administrator phranque is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month



Enter password: mysqldump: Got error: 1045: Access denied for user 'USER'@'localhost' (using password: NO) when trying to connect

you should enter as suggested by physics:

10 0 * * * cd /home/me/backups; /usr/bin/mysqldump --opt -u DBUSER -pDBPASS DBNAME > databasefile.sql

include the -p option and replace "DBPASS" with an actual password, since cron couldn't be bothered to provide one for you.
NO SPACE between "-p" and the password.
also make sure you replace "DBUSER" with a user that actually matches the provided password.

 

Featured Threads

Hot Threads This Week

Hot Threads This Month