Preface
 
    Connection security is  one of the most important safety strategies which we should consider.It's not a good manner using plaintext password in my.cnf file when connecting mysql server by client.What can we do more safely?
 
Introduce
 
    MySQL provide a method called "login-path" which permits merely using parameter "--login-path" to login MySQL server since 5.6 version.Notice,login-path depends on program "mysql_config_editor" which belongs to MySQL main program most probably in "/usr/local/mysql/bin" directory.First of all,we need to set a login path name(also a group name) with it,then the ".mylogin.cnf" will be created which contains user,password,host,port,socket and so forth.The password in ".mylogin.conf" file is shown as asterisks(eg. password=*****).Afterward,MySQL client will have a safer authentication credentials in loging MySQL servers.
 
Procedure
 
example
 
usage
 mysql_config_editor [program options] [command [command options]]
Parameter
  -#, --debug[=#]     This is a non-debug version. Catch this and exit.
-?, --help Display this help and exit.
-v, --verbose Write more information.
-V, --version Output version information and exit. Variables (--variable-name=value)
and boolean options {FALSE|TRUE} Value (after reading options)
--------------------------------- ----------------------------------------
verbose FALSE Where command can be any one of the following :
set [command options] Sets user name/password/host name/socket/port
for a given login path (section).
remove [command options] Remove a login path from the login file.
print [command options] Print all the options for a specified
login path.
reset [command options] Deletes the contents of the login file.
help Display this usage/help information.
Create a login path named "3306".
 [root@zlm1 :: ~]
#mysql_config_editor set --login-path= -h127.0.0. -P3306 -uroot -p
Enter password: [root@zlm1 :: ~]
#
Check the contents of login path.
 [root@zlm1 :: ~]
#mysql_config_editor print --all
[]
user = root
password = ***** -- Here is several asterisks instead of plaintest password.
host = 127.0.0.1
port =
Check the config file in user home directory.
 [root@zlm1 :: ~]
#ls -la|grep mylogin.cnf
-rw------- root root Jun : .mylogin.cnf [root@zlm1 :: ~]
#cat .mylogin.cnf -- All the contents in ".mylogin.cnf" file have been encrypted. ᑸ¨ƒˆK›巧-#[q- ¨ÿœ‰·t㼝«ɽ(žϿ欕鋳쾋 q̓‰أ&¸ۑ Sن}uj—–
ņZP‰ַ©ս¬ʨh±
[root@zlm1 :: ~]
#Xshell
Connect Server with client program by login path.
 [root@zlm1 :: ~]
#mysql --login-path=
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is
Server version: 5.7.-log MySQL Community Server (GPL) Copyright (c) , , 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. root@127.0.0.1: [(none)]>
Connect Server with client program by login path.

 [root@zlm1 :: ~]
#mysql --login-path=#
ERROR (): Access denied for user 'root'@'localhost' (using password: NO) [root@zlm1 :: ~]
#mysql_config_editor --print all
mysql_config_editor: [ERROR] unknown option '--print' [root@zlm1 :: ~]
#mysql_config_editor print --all
[]
user = root
password = *****
host = 127.0.0.1
port =
[#]
user = root
password = *****
host = 127.0.0.1
port =
 Remove a login path.

 [root@zlm1 :: ~]
#mysql_config_editor remove --login-path=# [root@zlm1 :: ~]
#mysql_config_editor print --all
[]
user = root
password = *****
host = 127.0.0.1
port =
 It's not supported using special character such as "#","¥",“%”,etc.

 [root@zlm1 :: ~]
#mysql_config_editor set --login-path=# -h127.0.0. -P3306 -uroot -p###
mysql_config_editor: [ERROR] mysql_config_editor: unknown option '-#' [root@zlm1 :: ~]
#mysql_config_editor set --login-path=# -h127.0.0. -P3306 -uroot -p$$$
mysql_config_editor: [ERROR] mysql_config_editor: unknown option '-3' [root@zlm1 :: ~]
#mysql_config_editor set --login-path=# -h127.0.0. -P3306 -uroot -p%%%
mysql_config_editor: [ERROR] mysql_config_editor: unknown option '-%'
 Summay

  • I'm afraid login-path is a safer method in logining MySQL.
  • Notice that characters of password must be confirmed to the MySQL password rules.
  • In the past,we usually put those parameters(host,port,user,password,etc.) in /etc/my.cnf to void repeated words typing,but it's realy not safe.
 

利用login-path对MySQL安全加固的更多相关文章

  1. lamp下mysql安全加固

    lamp下mysql安全加固 1.修改root用户口令,删除空口令 缺省安装的MySQL的root用户是空密码的,为了安全起见,必须修改为强密码,所谓的强密码,至少8位,由字母.数字和符号组成的不规律 ...

  2. 利用mysqltuner工具对mysql数据库进行优化

    mysqltuner工具使用,本工具建议定期运行,发现目前MYSQL数据库存在的问题及修改相关的参数 工具的下载及部署 解决环境依赖,因为工具是perl脚本开发的,需要perl脚本环境 # yun i ...

  3. 利用strace & Perf分析MySQL

    strace介绍及用途 strace是一个用于诊断,分析linux用户态进程的工具 类似的工具pstrace,lsof,gdb,pstrack strace观察mysqld对my.cnf 配置文件的加 ...

  4. 利用Docker快速部署Mysql

    写在前面 我又来更新了~~~,今天内容较少,主要是利用Docker快速部署Mysql和初始化数据 利用Docker下载Mysql 简洁明了,在命令提示符中输入 docker pull mysql:8. ...

  5. MYSQL启用日志,查看日志,利用mysqlbinlog工具恢复MySQL数据库【转载】

    转自 MYSQL启用日志,查看日志,利用mysqlbinlog工具恢复MySQL数据库 - _安静 - 博客园http://www.cnblogs.com/xionghui/archive/2012/ ...

  6. 在CentOS7中利用yum命令安装mysql

    在CentOS7中利用yum命令安装mysql 原创 2016年08月31日 10:42:33 标签: mysql / centos 4832 一.说明 我们是在VMware虚拟机上安装的mysql, ...

  7. 利用日志文件恢复MYSQL数据库

    利用日志文件恢复MYSQL数据库 650) this.width=650;" onclick='window.open("http://blog.51cto.com/viewpic ...

  8. docker数据卷学习-利用数据卷实现mysql的快速恢复和迁移

    docker数据卷学习 一 新建带有数据卷的容器 1.从docker hub下载centos7镜像 # docker pull centos 2. 创建container # docker run - ...

  9. 利用tcpdump抓取mysql sql语句

    这个脚本是我之前在网上无意间找个一个利用tcpdump 抓包工具获取mysql流量,并通过过滤把sql 语句输入. 脚本不是很长,但是效果很好. #!/bin/bash #this script us ...

随机推荐

  1. Angular JS例子 ng-repeat遍历输出

    首先要有Angular的插件:然后才开始遍历 :<!DOCTYPE html> <html lang="en"> <head> <meta ...

  2. 【Linux】动态链接函数库

    动静区别 1. gcc –c mylib.c –o mylib.o 2. gcc -shared -fPIC mylib.o -o libmylib.so 3. 将制作好的libmylib.so 复制 ...

  3. Matlab GUI选项卡

    1.在这个网址下载一个工具包,里面应该有四个文件:tabselectionfcp.p.tabselectionfcn.m.tabpanel.p和tabpanel.m,显然代码用.p格式进行加密了. 2 ...

  4. 导出word的另类做法

    一.背景 项目中经常有导出word的功能,一般用poi来做,但在要求外观较高的情况下,用poi来做基本不能满足需求 而事实上word除了我们一般使用的模式外,还存在xml.与html模式(你没看错,右 ...

  5. SQL Server ->> DISABLE索引后插入更新数据再REBUILD索引 和 保留索引直接插入更新数据的性能差异

    之前对于“DISABLE索引后插入更新数据再REBUILD索引 和 保留索引直接插入更新数据的性能差异”这两种方法一直认为其实应该差不多,因为无论如何索引最后都需要被维护,只不过是个时间顺序先后的问题 ...

  6. 使用WindowsService为宿主实装WCF 服务

    1. 写WCF服务   创建一个接口类,与一个实现类.接口类上打上[ServiceContract]标签,需要暴露的服务方法上打上[OperationContract] (注意:增加System.Se ...

  7. ORACLE_TRIGGER

    PL/SQL TRIGGER Statement PL/SQL TRIGGER  Statement The trigger statemet is a especially stored proce ...

  8. 增强for循环 java.util.ConcurrentModificationException

    Java中的Iterator功能比较简单,并且只能单向移动: (1) 使用方法iterator()要求容器返回一个Iterator.第一次调用Iterator的next()方法时,它返回序列的第一个元 ...

  9. HTTPS科普(转)

    为什么需要https HTTP是明文传输的,也就意味着,介于发送端.接收端中间的任意节点都可以知道你们传输的内容是什么.这些节点可能是路由器.代理等. 举个最常见的例子,用户登陆.用户输入账号,密码, ...

  10. Runloop理解

    看了一堂公开课,自己小结一下: Runloop: 内部有三个东东:(Source, Timer, Observer) 作用/本质:1.死循环 (为app 保活): 2.监听处理事件 Timer 理解: ...