全国免费服务热线:
18982081108
成都祈钰瑶
企业介绍
云服务器购买
弹性云服务器
高防云服务器
大带宽云服务器
联系我们
✕
成都祈钰瑶
企业介绍
云服务器购买
弹性云服务器
高防云服务器
大带宽云服务器
联系我们
成都弹性云服务器,成都高防云服务器,互联网数据服务,成都祈钰瑶
成都祈钰瑶
>>
网站建设知识
MySQL实现无密码登录(mysql_config_editor)
有一个业务需求是从一台主机上dump MySQL数据库的数据,但是又不想让业务人员知道具体MySQL用户的密码,可以用mysql_config_editor命令实现
一,测试环境
A机器IP为192.168.3.171
B机器IP为192.168.3.173
打算实现无“密码”从B连接到A
A和B的数据库版本
(root@localhost) [(none)]> select version();
+------------+
| version() |
+------------+
| 5.7.17-log |
+------------+
1 row in set (0.00 sec)
二,在A机器上创建测试用户并赋予权限
(root@localhost) [(none)]> create user gl@'192.168.3.173' identified by 'onlygl';
Query OK, 0 rows affected (0.00 sec)
(root@localhost) [(none)]> grant all on *.* to gl@'192.168.3.173';
Query OK, 0 rows affected (0.01 sec)
三,在B机器上执行如下命令,输入gl用户的密码
mysql_config_editor set --login-path=gl --host=192.168.3.171 --user=gl --password
四,执行上面命令后,可以在home的目录下找到一个隐藏文件.mylogin.cnf,如下:
-rw------- 1 root root 136 Feb 27 19:04 .mylogin.cnf
五,查看文件里的内容
[root@mysqltest ~]# mysql_config_editor print --all
[gl]
user = gl
password = *****
host = 192.168.3.171
六,登录
[root@mysqltest ~]# mysql --login-path=gl
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 311
Server version: 5.7.17-log Mysqlma
Copyright(c) 2000, 2016, Oracleand/or its affiliates. All rights reserved.
Oracleis a registered trademark of Oracle Corporationand/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.
(gl@192.168.3.171)[(none)]>
七,如果不想用了,用如下命令删除
mysql_config_editor remove --login-path=gl
八,适用范围
mysql
mysqladmin
mysqldump
九,总结
1.显而易见的是用户密码被修改后,需要重新创建login-path
2.该功能仅仅在5.6.6以上版本才支持
上一篇:
Golang捕获panic堆栈信息的讲解
下一篇:
原生javascript怎么实现移动端滑动banner效果
友情链接 :
成都弹性云服务器
app服务器配置
app服务器配置
安卓播放ftp服务器文件格式
便宜云虚拟主机购买怎么选择带宽
hp服务器怎么看型号和主机号
服务器连接加密保障信息安全
国外网站服务器租用好处有哪些
dns服务器地址设定错误怎么解决
找不到服务器报错怎么解决呢
正确选择网站服务器空间对网站有什么帮助?
首页
联系
电话