欢迎来到代码驿站!

Mysql

当前位置:首页 > 数据库 > Mysql

解决MySQL去除密码登录告警的问题

时间:2023-01-06 09:04:17|栏目:Mysql|点击:

背景

MySQL在命令行输入密码时会提示mysql: [Warning] Using a password on the command line interface can be insecure.,在某些时候会干扰取值。

解决方法:

使用mysql_config_editor可以解决这一问题。
login-path是从MySQL5.6开始支持的特性,借助mysql_config_editor工具可以将登陆MySQL的认证信息加密存放在.mylogin.cnf文件。之后,MySQL客户端可以通过读取该加密信息进行登陆。

示例:

[root@localhost mysql]# mysql_config_editor set --login-path=db_admin --host=192.168.1.6 --user=root --password
Enter password:         # 输入密码

参数

–login-path=name 登陆信息名称
–host=name 登陆地址
–password 在登陆文件中添加密码(该密码会被mysql_config_editor自动加密)
–user 用户名
–port=name 端口
–socket=name sock文件

查看

# 显示指定名称的登陆信息
mysql_config_editor print --login-path=test
# 显示所有登陆信息
mysql_config_editor print --all

示例:

[root@localhost mysql]# mysql_config_editor print --all
[db_admin]
user = root
password = *****
host = 192.168.1.6
[root@localhost mysql]# mysql_config_editor print --login-path=db_admin
[db_admin]
user = root
password = *****
host = 192.168.1.6

删除配置

mysql_config_editor remove --login-path=test

登陆

root@localhost mysql]# mysql --login-path=db_admin
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 10222
Server version: 5.7.37-log MySQL Community Server (GPL)
Copyright (c) 2000, 2022, Oracle and/or its affiliates.
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> 

上一篇:MySQL 分库分表的项目实践

栏    目:Mysql

下一篇:MySql主从复制机制全面解析

本文标题:解决MySQL去除密码登录告警的问题

本文地址:http://www.codeinn.net/misctech/223092.html

推荐教程

广告投放 | 联系我们 | 版权申明

重要申明:本站所有的文章、图片、评论等,均由网友发表或上传并维护或收集自网络,属个人行为,与本站立场无关。

如果侵犯了您的权利,请与我们联系,我们将在24小时内进行处理、任何非本站因素导致的法律后果,本站均不负任何责任。

联系QQ:914707363 | 邮箱:codeinn#126.com(#换成@)

Copyright © 2020 代码驿站 版权所有