简体   繁体   English

使用MyISAM和InnoDB表备份MySQL数据库

[英]Backup MySQL database with MyISAM & InnoDB tables

I have a MySQL database with mixed up tables (MyISAM, InnoDB). 我有一个混合表(MyISAM,InnoDB)的MySQL数据库。

How can I create a full backup of the database with mysqldump via Linux command line, what option should I use? 如何通过Linux命令行使用mysqldump创建数据库的完整备份,我应该使用哪个选项?

use below- 在下面使用

Generic command for all db's is- 所有数据库的通用命令是-

mysqldump -uroot -proot123 -A > /path/mydbbackup.sql

If you want to take few or all db's as per your choice then- 如果您希望根据自己的选择选择少量或全部数据库,则-

mysqldump -uroot -proot123 -B mydb1 mydb2 mydb3 > /path/mydbbackup.sql

If you want to avoid locking then use single transaction option- 如果您想避免锁定,请使用单个交易选项-

mysqldump --single-transaction -uroot -proot123 -A > /path/mydbbackup.sql

If you want to take specific db backup then- 如果您要进行特定的数据库备份,则-

mysqldump -uroot -proot123 mydb > /path/mydbbackup.sql

If you want to take a table backup then- 如果您要进行表备份,则-

mysqldump -uroot -proot123 mydb mytable > /path/mydbbackup.sql

where username is root and password is root123, you can change as per your's 用户名是root,密码是root123,您可以根据自己的

Note: mysqldump utility takes innodb and myisam both backups. 注意:mysqldump实用程序同时使用innodb和myisam备份。

There is no convenient solution currently: 当前没有方便的解决方案:

  • MyISAM tables need the option --lock-tables MyISAM表需要选项--lock-tables
  • InnoDB tables need the option --single-transaction --skip-lock-tables InnoDB表需要--single-transaction --skip-lock-tables选项

Both options are mutually exclusive. 这两个选项是互斥的。 You must select databases first and then dump them separately. 您必须先选择数据库,然后再分别转储它们。

Or... 要么...

If you have databases with both types of tables, just run mysqldump twice... 如果您的数据库具有两种类型的表,则只需运行mysqldump两次...

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM