在对mysql进行完整备份时使用--all-database参数

# mysqldump -u root -h localhost -p --all-database > /root/all.sql

数据导入的时候,可以先登陆mysql数据库中,使用source /root/all.sql进行导入。

如果想要在mysqldump备份数据库时过滤掉某些库,这种情况下就不能使用--all-database了,而是使用--database。如下备份数据库时过滤掉information_schema、mysql 、test和hehe_db库

[root@fangfull-backup ~]# mysql -uroot -p -e "show databases"
Enter password: +--------------------+
| Database |
+--------------------+
| information_schema |
| haha_db |
| hehe_db |
| mysql |
| test |
| tech_db |
| yaya_db |
| mimi_db |
| lala_db |
+--------------------+
9 rows in set (0.00 sec) [root@fangfull-backup ~]# mysql -uroot -p -e "show databases"|grep -Ev "Database|information_schema|mysql|test|hehe_db"
Enter password:
haha_db
tech_db
yaya_db
mimi_db
lala_db [root@fangfull-backup ~]# mysql -uroot -p -e "show databases"|grep -Ev "Database|information_schema|mysql|test|hehe_db"|xargs
Enter password:
haha_db tech_db yaya_db mimi_db lala_db [root@fangfull-backup ~]# mysql -uroot -p -e "show databases"|grep -Ev "Database|information_schema|mysql|test|hehe_db"|xargs mysqldump -uroot -p --databases > mysql_dump.sql
Enter password:

mysql5.6以上版本在直接使用密码登录mysql的时候,会出现提示信息"Warning: Using a password on the command line interface can be insecure."!

[root@kevin ~]# mysql -pkevin@123 -e "show databases"
Warning: Using a password on the command line interface can be insecure.
+--------------------+
| Database |
+--------------------+
| information_schema |
| confluence |
| dtin_uat |
| dtinlog_uat |
| mysql |
| nextcloud_db |
| performance_schema |
| xbtdb |
+--------------------+

要想屏蔽掉这个提示信息,方法是:将提示信息重定向到/dev/null,即忽略掉提示信息。

[root@kevin ~]# mysql -pkevin@123 -e "show databases" 2>/dev/null
+--------------------+
| Database |
+--------------------+
| information_schema |
| confluence |
| dtin_uat |
| dtinlog_uat |
| mysql |
| nextcloud_db |
| performance_schema |
| xbtdb |
+--------------------+ 过滤掉mysql某些库的操作如下:
[root@kevin ~]# mysql -pkevin@123 -e "show databases" 2>/dev/null |grep -Ev "Database|information_schema|mysql"
confluence
dtin_uat
dtinlog_uat
nextcloud_db
performance_schema
xbtdb

最新文章

  1. Parallel并行之乱用
  2. Maven入门示例(3):自动部署至外部Tomcat
  3. MVC3实现多个按钮提交
  4. js动态创建的元素绑定事件
  5. csharp: DataTable Rename ColumnName and remove Column
  6. 【Java】Float计算不准确
  7. 《算法导论》习题解答 Chapter 22.1-3(转置图)
  8. java中如何实现全局变量
  9. 我要爱死这个markdown 了
  10. try...catch...finally中try块发生的事件顺序
  11. 解决eclipse无法解析shared_ptr
  12. [LeetCode] Freedom Trail 自由之路
  13. ant 执行jmeter脚本
  14. linux screen 命令 :离线运行程序
  15. mui 总结
  16. LuoguP3834 【模板】可持久化线段树 1(主席树)|| 离散化
  17. Connecting Elixir Nodes with libcluster, locally and on Kubernetes
  18. Prometheus Node_exporter 详解
  19. JAVA内部线程2
  20. poj3190 Stall Reservations (贪心+优先队列)

热门文章

  1. 洛谷P1901发射站
  2. [SDOI2010][BZOJ 1925]地精部落
  3. js判断是不是在微信浏览器打开?
  4. 编译安装-httpd-2.2.15.tar.gz
  5. VMware 桥接网络设置
  6. Chapter Two
  7. 微信小程序之自定义底部弹出框动画
  8. TreeFrog Framework : High-speed C++ MVC Framework for Web Application http://www.treefrogframework.org
  9. JMS与消息队列
  10. 网络通信技术中的中继器repeater