MySQL 8.4 cheatsheet
MySQL 8.4: Backup and restore
3 common MySQL 8.4 tasks.
Back up a database
Write a SQL dump of one database. --single-transaction gives a consistent snapshot of InnoDB tables without locking them.
mysqldump -u root -p --single-transaction --routines mydb > mydb.sql
Back up every database
Write one SQL dump containing all databases.
mysqldump -u root -p --single-transaction --all-databases > all.sql
Restore a dump
Replay a SQL dump into a database that already exists.
mysql -u root -p mydb < mydb.sql
Caution: Statements in the dump can overwrite existing tables. Restore into a new database first if unsure.