MySQL 备份与恢复


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]

dump

mysqldump -u root --password=xxx DB_NAME [TABLE_NAME] > backup.sql

--password 可以直接在命令中使用密码

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

load

mysql -u root -p DB_NAME < backup.sql


评论区