一次导出和导入所有 MySQL 数据库

2021-11-20 00:00:00 mysql mysql-backup database-backups

我想备份我所有的 MySQL 数据库.我有 100 多个 MySQL 数据库.我想同时导出所有这些,然后再次将它们全部导入我的 MySQL 服务器.我该怎么做?

I want to keep a backup of all my MySQL databases. I have more than 100 MySQL databases. I want to export all of them at the same time and again import all of them into my MySQL server at one time. How can I do that?

推荐答案

导出:

mysqldump -u root -p --all-databases > alldb.sql

查找 mysqldump 文档.您可能想使用评论中提到的一些选项:

Look up the documentation for mysqldump. You may want to use some of the options mentioned in comments:

mysqldump -u root -p --opt --all-databases > alldb.sql
mysqldump -u root -p --all-databases --skip-lock-tables > alldb.sql

导入:

mysql -u root -p < alldb.sql

相关文章