mysql dumping and restoring

Author: yifei / Created: June 15, 2017, 3:06 p.m. / Modified: June 15, 2017, 3:35 p.m. / Edit

basic usage

the help message is pretty easy to read

Usage: mysqldump [OPTIONS] database [tables]
OR     mysqldump [OPTIONS] --databases [OPTIONS] DB1 [DB2 DB3...]
OR     mysqldump [OPTIONS] --all-databases [OPTIONS]
  1. dump

mysqldump -u root -p DB_NAME [TABLE_NAME] > backup.sql

可以选择只 dump 一个数据库或者一个表

  1. load

mysql -u root -p DB_NAME < backup.sql