Intellipaat Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in Linux by (9.5k points)

I’ve my data on the MYSQL database. Can anyone tell me how to download the MYSQL dump from the command line? 

1 Answer

0 votes
by (19.7k points)

This can be done with mysqldump function. See the below examples:

  1. For a single whole DB 

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

  1. For able within a DB 

$ mysqldump -u [uname] -p db_name table1 table2 > table_backup.sql

  1. To auto-compress the output, use gzip:

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

  1. To do it remotely and you have the server access 

$ mysqldump -P 3306 -h [ip_address] -u [uname] -p db_name > db_backup.sql

It should drop the .sql file in the folder you run the command-line from.

EDIT: Updated to avoid inclusion of passwords in CLI commands, use the -p option without the password. It will prompt you for it and not record it.

Interested in Linux? Check out this Linux Certification by Intellipaat.  

Related questions

0 votes
1 answer
0 votes
1 answer
0 votes
1 answer
0 votes
1 answer

Browse Categories

...