10

I am trying to backup my databases through the terminal in Ubuntu using the mysqldump command and it's successful. Where does it place the backed up databases?

I run the command like this:

$ mysqldump -h localhost -u username - p database_name > back_up_db.sql

but have no idea where back_up_db.sql is stored.

migrated from stackoverflow.com Mar 1 '11 at 13:47

This question came from our site for professional and enthusiast programmers.

12

By default it does it to the console. You need to redirect the output to a file if you need to save it.

The place you put the backup is up to you. Ideally, it should be on a different machine in a different physical location. This is why you usually do a remote MySQL dump over SSH and get the data on a different machine. You just pipe the console output over ssh into a file on a different machine.

10

It should also be noted that the mysqldump command also has a switch for a destination file.

--result-file=file_name, -r file_name
7

Usually you use mysql dump like this

mysqldump -h host -u user -ppassword dbname > dumpfile

So the output is whatever file you redirect output to. The output file will contain instructions that will rebuild the database from scratch, including the schema, if your run it on a new install like so.

mysql -h host -u user -ppassword dbname < dumpfile

Here's wiki on IO redirection

1

It will be stored in the path or folder from where you run the mysql commandenter image description here suppose you run the command from root then it will be stored in the root directory

you can see my backup file skillmappingcleardata.sql in the root directory because I run the mysql command from there

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy