查看现在有哪些数据库需要备份
MariaDB [(none)]> show databases;
±-------------------+
| Database |
±-------------------+
| Wecenter |
| bbs |
| blog |
| information_schema |
| mysql |
| performance_schema |
| webdb |
±-------------------+
7 rows in set (0.01 sec)
MariaDB [(none)]>
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
现在我们要备份的数据库有blog数据库,webdb数据库
进入到保存备份数据的目录
[root@xinsz08 backup]# cd backup/
- 1
开始备份
[root@xinsz08 backup]# mysqldump -uroot -p blog >blog202007302109.sql
[root@xinsz08 backup]# mysqldump -uroot -p webdb > wedb202007302109.sql
Enter password:
- 1
- 2
- 3
查看备份好的数据:
[
root@xinsz08 backup]# ll -h
total 11M
-rw-r--r-- 1 root root 361K Jul 30 21:10 blog202007302109.sql
-rw-r--r-- 1 root root 11M Jul 30 21:33 wedb202007302109.sql
[root@xinsz08 backup]#
- 1
- 2
- 3
- 4
- 5
一个11M,一个361K,都不是很大,其中361K的是今天刚建好的个人站。
2. 备份多个数据库
[root@xinsz08 backup]# mysqldump -uroot -p --datadases blog, webdb > back.sql
- 1
3. 备份所有数据库
[root@xinsz08 backup]# mysqldump -uroot -p --all-databases > databaseall-20200730all.sql
Enter password:
[root@xinsz08 backup]# ll -h
total 23M
-rw-r--r-- 1 root root 361K Jul 30 21:10 blog202007302109.sql
-rw-r--r-- 1 root root 12M Jul 30 21:37 databaseall-20200730all.sql
-rw-r--r-- 1 root root 11M Jul 30 21:33 wedb202007302109.sql
- 1
- 2
- 3
- 4
- 5
- 6
- 7
总结
本文是在操作过程中随时做的记录,事实上是有脚本随时生成备份的,这个我们会在后面的篇章里来详细介绍关于mysql和shell脚本的内容
</div><div data-report-view="{"mod":"1585297308_001","dest":"https://blog.csdn.net/xinshuzhan/article/details/107701328","extend1":"pc","ab":"new"}"><div></div></div>
<link href="https://csdnimg.cn/release/phoenix/mdeditor/markdown_views-e0530931f4.css" rel="stylesheet">
</div>