The mysqldump
command is used to create a backup of a MySQL database by exporting its structure and data into a .sql
file.
Syntax:
mysqldump -u username -p database_name > /path/to/backup.sql
Parameters:
-u username
: Specifies the MySQL username.-p
: Prompts for the MySQL password.database_name
: The name of the database to be dumped.> /path/to/backup.sql
: Redirects the output to a specified file.Example:
mysqldump -u root -p my_database > /home/ubuntu/my_database_backup.sql