zoukankan      html  css  js  c++  java
  • mysql本地指定loginpath免密登录(mysql_config_editor的用法)

    ###

    1、前言

    我们通常登陆mysql都是用如下命令登陆,命令很长而且密码如果超级复杂的话,每次登陆还要输入密码;复杂的密码不仅难记,还容易输错,非常蛋疼 
    mysql_config_editor这个命令就为我们解决了这一蛋疼的问题 正常登陆方法: mysql
    -uroot -p -S /tmp/mysql3306.sock

    2、生成一个mylogin.cnf文件

    [root@zw-test-db /]# mysql_config_editor set --login-path=dev-mysql-01 --user=root --socket=/tmp/mysql3306.sock --password
    Enter password: 
    
    [root@zw-test-db mysql]# cat ~/.mylogin.cnf 
    
    ^@^@^@^@^]^E^\^M^]^X^Z^O^A^W^D^A^A^W^C^L^Z^Q^V^O^P^@^@^@E8¼é$Go¾Ò^]<99>
    SgO^P^@^@^@ÏC:@}w½öètËíRÁWK ^@^@^@^A"p9<86>^\+ñ7GìÞ<80>ZP<9a>¾tLÆø<86>·<34<81>­þe<91>^T ^@^@^@p} Qý1ÛÀk<86>b!<96>ªP^Rå<87>^_Õ~åºt <89>÷á|Ü<82>²
    
    可以看到一串加密的文件

    3、打印一下生成文件的内容

    [root@zw-test-db ~]# mysql_config_editor print --all
    [dev-mysql-01]
    user = root
    password = *****
    socket = /tmp/mysql3306.sock

    4、用加密文件登陆

    [root@zw-test-db ~]# mysql --login-path=dev-mysql-01
    Welcome to the MySQL monitor.  Commands end with ; or \g.
    Your MySQL connection id is 3
    Server version: 5.7.14-log MySQL Community Server (GPL)
    
    Copyright (c) 2000, 2016, 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> 
    
    以后登陆就不用输入超长的密码啦!



    原文链接:https://blog.csdn.net/zhengwei125/article/details/52414284

    ###

  • 相关阅读:
    PostgreSQL Monitor pg_activity
    bzoj2333 [SCOI2011]棘手的操作
    bzoj1499 [NOI2005]瑰丽华尔兹
    bzoj2561 最小生成树
    bzoj2038 [2009国家集训队]小Z的袜子(hose)
    bzoj2002 [Hnoi2010]Bounce 弹飞绵羊
    bzoj3589 动态树
    bzoj4034 [HAOI2015]树上操作
    bzoj4774 修路
    2018.1.14 省选模拟赛
  • 原文地址:https://www.cnblogs.com/faithH/p/15657416.html
Copyright © 2011-2022 走看看