The mysql_config_editor utility enables you to store authentication credentials in an obfuscated login path file named .mylogin.cnf. The file location is the %APPDATA%\MySQL directory on Windows and the current user's home directory on non-Windows systems. The file can be read later by MySQL client programs to obtain authentication credentials for connecting to MySQL Server.
【该mysql_config_editor实用程序,可以存储在一个名为模糊化的登录路径文件认证证书.mylogin.cnf。文件位置是%APPDATA%\MySQLWindows 上的目录和非 Windows 系统上当前用户的主目录。MySQL 客户端程序稍后可以读取该文件以获取用于连接到 MySQL 服务器的身份验证凭据。】
.mylogin.cnf 登录路径文件 的非混淆格式由选项组组成,类似于其他选项文件。在每个选项组 .mylogin.cnf被称为“登录路径, ”这是一组只允许特定的选项:host,user, password,port和 socket。将登录路径选项组视为一组选项,用于指定要连接到的 MySQL 服务器以及要进行身份验证的帐户。
在客户端配置案例:
# mysql_config_editor set --login-path=mylogin --user=root --host=localhost --port=3306 --password
Enter password:
查看配置:
# mysql_config_editor print --all
[dbadmin]
user = root
password = *****
host = localhost
port = 3306
[mylogin]
user = root
password = *****
host = localhost
port = 3306
连接使用:
# mysql --login-path=mylogin
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 42
Server version: 5.7.33-log MySQL Community Server (GPL)
Copyright (c) 2000, 2021, 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>
当您调用客户端程序连接到服务器时,客户端会.mylogin.cnf与其他选项文件一起使用。它的优先级高于其他选项文件,但低于客户端命令行上明确指定的选项。有关使用选项文件的顺序的信息。
mysql_config_editor对.mylogin.cnf文件进行混淆处理,因此无法将其作为明文读取,并且客户端程序未混淆的 内容仅在内存中使用。通过这种方式,密码可以以非明文格式存储在文件中并在以后使用,而无需在命令行或环境变量中公开。mysql_config_editor提供了一个print用于显示登录路径文件内容的 命令,但即使在这种情况下,密码值也会被屏蔽,以便永远不会以其他用户可以看到的方式出现。
mysql_config_editor 使用的混淆 防止密码.mylogin.cnf以明文形式出现,并通过防止无意中暴露密码来 提供安全措施。例如,如果您my.cnf在屏幕上显示常规的未混淆 选项文件,则任何人都可以看到其中包含的任何密码。有了 .mylogin.cnf,这是不正确的。但是所使用的混淆不太可能阻止坚定的攻击者,您不应该认为它牢不可破。可以在您的机器上获得系统管理权限以访问您的文件的用户可以.mylogin.cnf 通过一些努力来取消混淆文件。
登录路径文件必须对当前用户可读可写,其他用户不可访问。否则, mysql_config_editor 会忽略它,客户端程序也不使用它。
]# mysql_config_editor --help
mysql_config_editor Ver 1.0 Distrib 5.7.33, for linux-glibc2.12 on x86_64
Copyright (c) 2012, 2021, 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.
MySQL Configuration Utility.
Usage: mysql_config_editor [program options] [command [command options]]
-#, --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.
本文介绍mysql_config_editor实用程序,用于安全地存储MySQL客户端连接所需的认证凭证。通过创建.mylogin.cnf文件,用户可以为不同的登录路径设置用户名、密码等信息,并在后续连接中使用这些路径简化认证过程。
2371

被折叠的 条评论
为什么被折叠?



