diff --git a/source/_posts/MySQL.md b/source/_posts/MySQL.md new file mode 100644 index 0000000..59de64c --- /dev/null +++ b/source/_posts/MySQL.md @@ -0,0 +1,47 @@ +# MySQL + +## mysqldump备份数据库 + +### 备份实例下的所有库 + +```shell +mysqldump -uroot -p -A > all.sql +``` + +### 备份单个指定数据库 + +```shell +mysqldump -uroot -p test > test.sql +``` + +### 备份多个指定数据库 + +```shell +mysqldump -uroot -p test1 test2 > test12.sql +``` + +### 备份指定数据库中的单个表 + +```shell +mysqldump -uroot -p test user > test.user.sql +``` + +### 备份指定数据库中的多个表 + +```shell +mysqldump -uroot -p test user role > test.ur.sql +``` + +### 备份数据库表结构只包含DDL语句 + +```shell +# --no-data 或 -d +mysqldump -uroot -p test --no-data > test.sql +``` + +### 备份数据库带库名 + +```shell +mysqldump -uroot -p -B test > test.sql +``` +