• mysqlpump 和 mysql_config_editor测试


    The mysql_config_editor utility enables you to store authentication credentials in an obfuscated login path file named .mylogin.cnf. The file location is the %APPDATA%MySQL directory on Windows and the current user's home directory on non-Windows systems. The file can be read later by MySQL client programs to obtain authentication credentials for connecting to MySQL Server.

    The unobfuscated format of the .mylogin.cnf login path file consists of option groups, similar to other option files. Each option group in .mylogin.cnf is called a login path,” which is a group that permits only certain options: host, user, password, port and socket. Think of a login path option group as a set of options that specify which MySQL server to connect to and which account to authenticate as. Here is an unobfuscated example: (该工具的作用就是将mysql的登录凭证写到一个默认的.mylogin.cnf配置文件里,然后在执行命令mysql --login-path=mypath时,会使用该配置文件里的凭证自动登录)

    [client]
    user = mydefaultname
    password = mydefaultpass
    host = 127.0.0.1
    [mypath]
    user = myothername
    password = myotherpass
    host = localhost
    1. 设置MySQL免密码登录
    mysql_config_editor set --login-path=testlogin --user=root --host=localhost --password
    执行上面的命令后,mysql 会提示你输入root的密码。
    该命令会在root的home目录下创建一个.mylogin.cnf配置文件,内容为加密状态,包含上面的mysql登录时需要用到的帐号密码、服务器等。

    2. 创建备份脚本
    # vi testbackupdb.sh
    #!/bin/bash
    echo 'Begin Backup test DB'
    
    DATE1=`date -d "now" +%Y%m%d_%H%M%S`
    mysqlpump --login-path=testlogin --default-character-set=UTF8MB4 --single-transaction --compress-output=LZ4 --default-parallelism=3 -B testdb 
    --log-error-file=/root/db_backup/logs/testdb_bak_$DATE1.log >/root/db_backup/testdb_bak_$DATE1.sql.lz
    3. 添加定时任务
    # crontab -e
    01 02 * * * /root/db_backup/testbackupdb.sh
     
  • 相关阅读:
    54. 八皇后问题[eight queens puzzle]
    53. 特殊的O(n)时间排序[sort ages with hashtable]
    52. 不用+、-、×、÷做加法[add two numbers without arithmetic]
    C++基础知识面试精选100题系列(11-20题)[C++ basics]
    C++基础知识面试精选100题系列(1-10题)[C++ basics]
    洛谷 P1479 宿舍里的故事之五子棋
    洛谷 P2084 进制转换
    codevs 1700 施工方案第二季
    POJ 3278 Catch That Cow(求助大佬)
    POJ 2251 Dungeon Master
  • 原文地址:https://www.cnblogs.com/rusking/p/10755976.html
Copyright © 2020-2023  润新知