MySQL provides the mysqldump command to create backups.
Command to Backup a Database:
mysqldump -u root -p database_name > backup.sql
mysqldump → Utility for exporting database data.-u root -p → Specifies the database user (root) and asks for a password.database_name > backup.sql → Saves the backup in a .sql file.To restore a database from a backup file, use the mysql command.
Command to Restore a Database:
mysql -u root -p database_name < backup.sql
mysql → MySQL command-line tool.database_name < backup.sql → Restores data from backup.sql to database_name.Regular backups are crucial for data security and disaster recovery. Using MySQL’s mysqldump and mysql commands, you can efficiently backup and restore databases, ensuring business continuity.