解决MySQL去除密码登录告警的问题
作者:忘川的彼岸 时间:2024-01-26 12:33:21
背景
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>
来源:https://www.cnblogs.com/os-linux/p/16168527.html
标签:mysql,密码,登录,告警
0
投稿
猜你喜欢
Python中Jieba进行词频统计与关键词提取
2022-02-03 23:08:50
详解Python垃圾回收机制和常量池的验证
2022-12-28 09:58:29
深入理解NumPy简明教程---数组2
2022-03-24 05:01:18
python爬虫租房信息在地图上显示的方法
2021-12-13 03:22:57
Python全栈之文件函数和函数参数
2023-05-11 02:28:21
JS密码生成与强度检测完整实例(附demo源码下载)
2024-04-25 13:13:07
python判断完全平方数的方法
2023-07-12 06:43:13
Python Pygame中精灵和碰撞检测详解
2021-01-31 05:45:27
详解使用uni-app开发微信小程序之登录模块
2024-05-11 09:15:57
一文带你探寻Python中的装饰器
2021-07-11 10:17:59
解析SQLServer获取Excel中所有Sheet的方法
2024-01-18 15:11:26
三条asp语句搞定路径
2007-10-22 13:30:00
在uni-app中使用element-ui的方法与报错解决
2024-05-29 22:29:44
Python版名片管理系统
2021-08-28 18:51:22
python实现感知器
2021-03-18 09:12:13
实例详解Python中的numpy.abs和abs函数
2023-03-09 08:06:38
js自定义快捷,IE,FF有良好的支持
2007-08-25 17:34:00
手工打造极酷的分离式滑动门导航菜单
2009-05-25 20:11:00
让IE6更快的走向灭亡
2010-02-03 15:05:00
Python实现批量读取HDF多波段栅格数据并绘制像元直方图
2023-08-20 17:27:08