BellHopByDayAmetuerCoderByNigh BellHopByDayAmetuerCoderByNigh - 10 months ago 63
MySQL Question

Where Are MySQL DB Backups Stored

I just ran

mysqldump --all-databases > dump-$( date '+%Y-%m-%d_%H-%M-%S' ).sql -u root -p
but I can not locate the database location on my
Ubuntu 16.04
system. What location did this database get created in?

Answer Source

The > symbol redirects stdout from the command preceding the symbol to the file location following the symbol mycommand > outputfile.txt. In your case you need to pass the username and password flags to the mysqldump command. In your attempt you are putting the flags on the wrong side of the > redirect.

mysqldump --all-databases -u root -p > dump-$( date '+%Y-%m-%d_%H-%M-%S' ).sql

Since a directory wasn't specified for that file it will write to whatever directory you are currently in. You can be more explicit by specifying the directory:

 mysqldump --all-databases -u root -p > ~/mysql_backups/dump-$( date '+%Y-%m-%d_%H-%M-%S' ).sql