Search code examples
mysqlcommand-linexamppmariadbcommand-line-arguments

Where does mysqldump files go?


I've read a post saying that I would have to use this command below, to dump my sql files

$ mysqldump -u [uname] -p db_name > db_backup.sql

However, my question is, I don't quite get where the db_backup.sql comes from. Am I suppose to create a file or is it being created as I enter any name for the backup sql? Also, where can I find the backup.sql at?

More information: I am doing this on Mariadb/phpmyadmin on the xampp shell


Solution

  • Whichever directory you are in when you run that command will have db_backup.sql.

    The statement:

    mysqldump -u user -p db_name generates an output on the terminal screen, assuming you are SSH'ed into the server. Instead of the output written on the screen, you can redirect the output to a file.

    To do that, you use > db_backup.sql after the command.

    If you are in directory /home/hyunjae/backups and run the command:

    $ mysqldump -u [uname] -p db_name > db_backup.sql

    You will see a new file created called db_backup.sql. If there's already a file with that name, it will be overwritten.

    If you don't know what directory you are in, you can type pwd for present working directory.