简体   繁体   中英

Backup MySQL database with MyISAM & InnoDB tables

I have a MySQL database with mixed up tables (MyISAM, InnoDB).

How can I create a full backup of the database with mysqldump via Linux command line, what option should I use?

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

Note: mysqldump utility takes innodb and myisam both backups.

There is no convenient solution currently:

  • MyISAM tables need the option --lock-tables
  • InnoDB tables need the option --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...

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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