zoukankan      html  css  js  c++  java
  • MySQL 备份时过滤掉某些库 以及 去掉Warning提示信息

    在对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
  • 相关阅读:
    Google调试技巧总结
    Reorder List -- leetcode
    Java回合阵列List
    他们控制的定义(2.3):SurfaceView和SurfaceHolder
    ImageView建立selector在录音中遇到的小问题及解决方案
    cocos2d 简单的日常高仿酷跑游戏
    Xcode的小标记旁边的文件的名称的作用
    c++中的对象引用(object reference)与对象指针的区别
    UIColor深入研究(CGColor,CIColor)
    UIImage图片处理
  • 原文地址:https://www.cnblogs.com/kevingrace/p/5950512.html
Copyright © 2011-2022 走看看