使用mysql_config_editor 管理mysql登录

如果不想每次登录mysql 数据库时都输入密码时,可以使用
如下命令进行密码管理

1、mysql_config_editor set  --login-path=mysql_3306 --host=10.10.10.10 --user=root --port=3306 --password

2、mysql_config_editor  set --login-path=mysql_3307 --socket=/data/3307/tmp/mysql.sock --port=3307 --user=root --password
登录
mysql --login-path=mysql_3306

mysql --login-path=mysql_3307

查看详细信息:

mysql_config_editor print --login-path=mysql_3306
[mysql_3306]
user = root
password = *****
socket = /data/3306/tmp/mysql.sock


修改信息

mysql_config_editor reset --log-path=mysql_3306 --user=root --password --host=10.10.10.10

[root@db2 ~]# mysql_config_editor  set --help
mysql_config_editor Ver 1.0 Distrib 5.7.26, for linux-glibc2.12 on x86_64
Copyright (c) 2012, 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.

MySQL Configuration Utility.

Description: Write a login path to the login file.
Usage: mysql_config_editor [program options] [set [command options]]
  -?, --help          Display this help and exit.
  -h, --host=name     Host name to be entered into the login file.
  -G, --login-path=name 
                      Name of the login path to use in the login file. (Default
                      : client)
  -p, --password      Prompt for password to be entered into the login file.
  -u, --user=name     User name to be entered into the login file.
  -S, --socket=name   Socket path to be entered into login file.
  -P, --port=name     Port number to be entered into login file.
  -w, --warn          Warn and ask for confirmation if set command attempts to
                      overwrite an existing login path (enabled by default).
                      (Defaults to on; use --skip-warn to disable.)

Variables (--variable-name=value)
and boolean options {FALSE|TRUE}  Value (after reading options)
--------------------------------- ----------------------------------------
host                              (No default value)
login-path                        client
user                              (No default value)
socket                            (No default value)
port                              (No default value)
warn                              TRUE
[root@db2 ~]# mysql_config_editor --print
mysql_config_editor: [ERROR] unknown option '--print'
[root@db2 ~]# mysql_config_editor print

[root@db2 ~]# mysql_config_editor print --login-path=mysql_3306
[mysql_3306]
user = root
password = *****
socket = /data/3306/tmp/mysql.sock

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值