homepage Welcome to WebmasterWorld Guest from 54.196.63.93
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member

Home / Forums Index / Code, Content, and Presentation / Databases
Forum Library, Charter, Moderator: open

Databases Forum

    
Cron job to backup mysql database
what I do wrong?
meetzah2

5+ Year Member



 
Msg#: 3277413 posted 10:01 am on Mar 10, 2007 (gmt 0)

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

10+ Year Member



 
Msg#: 3277413 posted 12:28 pm on Mar 10, 2007 (gmt 0)

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

-uusername -ppassword

phranque

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



 
Msg#: 3277413 posted 12:36 pm on Mar 10, 2007 (gmt 0)

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

WebmasterWorld Senior Member 10+ Year Member



 
Msg#: 3277413 posted 7:29 pm on Mar 10, 2007 (gmt 0)

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

5+ Year Member



 
Msg#: 3277413 posted 10:32 am on Mar 12, 2007 (gmt 0)

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

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



 
Msg#: 3277413 posted 2:49 pm on Mar 13, 2007 (gmt 0)

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.

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / Databases
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved