🖥️mysqldump

➡️This is a command-line reference manual for commands and command combinations that you don’t use often enough to remember it. This cheatsheet explains the mysqldump command with important options and switches using examples.

▁ ▂ ▃ ▄ ꧁ 🔴☠ COMMANDLINE-KUNGFU WITH CHEATSHEETS ☠🔴꧂▅ ▃ ▂ ▁

#      ███╗   ███╗██╗   ██╗███████╗ ██████╗ ██╗     ██████╗ ██╗   ██╗███╗   ███╗██████╗ 
#      ████╗ ████║╚██╗ ██╔╝██╔════╝██╔═══██╗██║     ██╔══██╗██║   ██║████╗ ████║██╔══██╗
#      ██╔████╔██║ ╚████╔╝ ███████╗██║   ██║██║     ██║  ██║██║   ██║██╔████╔██║██████╔╝
#      ██║╚██╔╝██║  ╚██╔╝  ╚════██║██║▄▄ ██║██║     ██║  ██║██║   ██║██║╚██╔╝██║██╔═══╝ 
#      ██║ ╚═╝ ██║   ██║   ███████║╚██████╔╝███████╗██████╔╝╚██████╔╝██║ ╚═╝ ██║██║     
#      ╚═╝     ╚═╝   ╚═╝   ╚══════╝ ╚══▀▀═╝ ╚══════╝╚═════╝  ╚═════╝ ╚═╝     ╚═╝╚═╝     
                

                                                                                                
# To dump a database to a file (Note that your password will appear in your command history!):
mysqldump -uusername -ppassword the-database > db.sql

# To dump a database to a file:
mysqldump -uusername -p the-database > db.sql

# To dump a database to a .tgz file (Note that your password will appear in your command history!):
mysqldump -uusername -ppassword the-database | gzip -9 > db.sql

# To dump a database to a .tgz file:
mysqldump -uusername -p the-database | gzip -9 > db.sql

# To dump all databases to a file (Note that your password will appear in your command history!):
mysqldump -uusername -ppassword --all-databases > all-databases.sql

# To dump all databases to a file:
mysqldump -uusername -p --all-databases > all-databases.sql

# To export the database structure only:
mysqldump --no-data -uusername -p the-database > dump_file

# To export the database data only:
mysqldump --no-create-info -uusername -p the-database > dump_file

# backup all data in compressed format - error out to a different file every day if it is part of a cron entry. The backup file will overwrite older version.
mysqldump --routines --all-databases | gzip > /home/mydata.sql.gz 2> /home/mydata.date '+\%b\%d'.err

# Monitor ETA using pv command - You can get an approximate idea of how long your data export might take.
mysqldump --login-path=mypath sbtest sbtest4 | pv --progress --size 200m -t -e -r -a > dump.sql
    # Sample output
	    # [==================================>  ] 60% ETA 0:00:01

#==============================##==============================#
# CMD MYSQLDUMP						       #
#==============================##==============================#
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░

  █║▌│║█║▌★ KALI ★ PARROT ★ DEBIAN 🔴 PENTESTING ★ HACKING ★ █║▌│║█║▌

              ██╗ ██╗ ██████╗  ██████╗ ██╗  ██╗███████╗██████╗
             ████████╗██╔══██╗██╔═══██╗╚██╗██╔╝██╔════╝██╔══██╗
             ╚██╔═██╔╝██║  ██║██║   ██║ ╚███╔╝ █████╗  ██║  ██║
             ████████╗██║  ██║██║   ██║ ██╔██╗ ██╔══╝  ██║  ██║
             ╚██╔═██╔╝██████╔╝╚██████╔╝██╔╝ ██╗███████╗██████╔╝
              ╚═╝ ╚═╝ ╚═════╝  ╚═════╝ ╚═╝  ╚═╝╚══════╝╚═════╝

               █║▌│║█║▌ WITH COMMANDLINE-KUNGFU POWER █║▌│║█║▌

░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░