zoukankan      html  css  js  c++  java
  • Mysql-备份免密登录方法

    前言:
    最近写数据库备份脚本时,将备份用户和密码写到脚本中执行备份,发现crontab执行备份脚本时候,mysql报错提示:Warning: Using a password on the command line interface can be insecure,告知此行为不安全。crontab退出执行脚本,没有执行成功。然后就想到做一个备份时候免密登录,不需要用户和密码放在脚本中,即安全又不会报错的方法。
     
    1:执行mysql_config_editor命令,执行完成后,会在当前用户目录生成一个.mylogin.cnf文件
    说明:
    --login-path:登录时调用的名称
    --user:免密登录的用户
    --host:免密登录的用户主机
    --password:免密登录的用户密码
    [root@localhost ~]# mysql_config_editor set --login-path=test --user=root --host=localhost --password

    2:通过指定生成的.mylogin.cnf文件直接进入mysql

    [root@localhost ~]# mysql --login-path=test
    Welcome to the MySQL monitor.  Commands end with ; or g.
    Your MySQL connection id is 20
    Server version: 5.6.45 MySQL Community Server (GPL)
    
    Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved.
    
    Oracle is a registered trademark of Oracle Corporation and/or its
    affiliates. Other names may be trademarks of their respective
    owners.
    
    Type 'help;' or 'h' for help. Type 'c' to clear the current input statement.
    
    mysql> 
  • 相关阅读:
    数据统计
    判断文件是否改变
    多列表统计之后的数组排序
    被弃用的php函数以及被那个代替
    curl数据采集
    MySQL教程
    使用多次join数据重复的问题
    ThinkPHP5高阶实战教程 --诠释为API开发而生
    SpringBoot使用thymeleaf模板
    SpringBoot与JPA
  • 原文地址:https://www.cnblogs.com/douyi/p/13553649.html
Copyright © 2011-2022 走看看