The “mysqldump” command is used on the command line to dump databases managed by MySQL. There are several instances where one may wish to dump a database or part of a database and here we consider three of the most useful cases.
The first case is when the whole database needs to be backed up or dumped. This is done using the following command on the command line interface (CLI):
mysqldump -u username -p password database_name > database_name_dump.sql
The second instance is when just a single table within the database needs to be dumped or exported. In this situation, the following should be executed on the command line interface:
mysqldump -u username -p password database_name database_table_name > database_table_dump.sql
And the third instance is when you want to dump only rows that meet a specific criteria. In this case you can use the “where” option on the command line interface (CLI) when you execute the “mysqldump” command. This example will dump only rows where date_created is today (09 October 2019):
mysqldump -u username -p password database_name table_name –where=”date_created=’2019-10-09′” > todays_rows_dump.sql