MySQL of MySQL_ config_ Editor summary




mysql_config_editoryesMySQLWith a security encryption login tool, you can avoid using password plaintext in some occasions, for example, writeshellWhen scripting, there is no need to worry about writing clear text password in the script; it can also be used to manage multiple stationsMySQLexample. In addition, if you usemysqlThe command can log in to the database to avoid entering a bunch of parameters each time. Simple and convenient.


The official documents are as follows:


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.





Help information view


# mysql_config_editor --help
mysql_config_editor Ver 1.0 Distrib 5.7.30, for Linux on x86_64
Copyright (c) 2012, 2020, 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
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.




New configurationlogin path


mysql_config_editorThe corresponding parameter information is as follows:


·         help Show help

·         –login-path=name,-G name

·         –host=host_name,-h host_name host name

·         –password,-p Password. This is not a place to use=Write password directly

·         –port=port_num,-P port_num Port number

·         –socket=file_names,-S file_name file name

·         –user=user_name,-u user_name user name

·         –warn,-w If you want to ignore the warning, use the–skip-warn parameter




#mysql_config_editor set –login-path=dbadmin –user=root  –host=localhost –port=3306 –password




You’ll find new additionslogin pathAfter that, a hidden file will be generated in the root directory of the current user.mylogin.cnf(If it isWindowsThis file is located in%APPDATA%\MySQLBelow the table of contents)



# ls -lrt ~/.mylogin.cnf
-rw-------. 1 root root 156 Aug 14 15:32 /root/.mylogin.cnf
# hexdump ~/.mylogin.cnf
0000000 0000 0000 0e16 0c1f 1014 1915 0910 1b01
0000010 0b08 000e 0b11 1516 0010 0000 7c87 f22d
0000020 b92c 751f 4750 d5bd 3db3 1558 0010 0000
0000030 7b3b 4bcf a986 0921 5ea2 197f 5ad7 9cd2
0000040 0020 0000 2b28 3ecc ffee 9d8e 70c5 c9ac
0000050 8a40 2e89 74dd a9db f67f 34d1 f0b2 10b5
0000060 d7f0 2c17 0020 0000 30b5 8f7f 9f20 dc0d
0000070 63a8 c83e 17a0 7792 997d 23e4 02ee c788
0000080 de49 c2da cd06 9993 0010 0000 1e9f c904
0000090 e3dd ea6c 8db5 d28a b17e dfc7          



Printing/View configurationlogin path



# mysql_config_editor print –login-path=dbadmin


user = root

password = *****

host = localhost

port = 3306




#View alllogin pathinformation


# mysql_config_editor print –all





Clear configurationlogin path



# mysql_config_editor reset

# mysql_config_editor print –all



Delete configurationlogin path



# mysql_config_editor remove –login-path=dbadmin



It can also be deletedlogin pathOne of the items in.


-h,host=name add tohostGo to the login file

-Glogin-path=name In the login file forlogin pathAdd name (default isclient

-p,password Add a password to the login file (the password will bemysql_config_editorAutomatic encryption)

-uuser Add the user name to the login file

-S,socket=name add tosockFile path to the login file

-Pport=name Add the login port to the login file





1mysql_config_editor can not deal password with “#”



usemysql_config_editorCreatedlogin pathAfter using is encountered this error.


# mysql –login-path=admin

ERROR 1045 (28000): Access denied for user ‘root’@’localhost’ (using password: YES)




The reason for the error is that the account password contains special characters#Created inlogin pathThe password must be wrapped in double quotation marks to avoid this error. In fact, this is not exactly oneBug,Because of parsing.mylogin.cnfWhen the#As a notation.


The problem is that the .mylogin.cnf file interprets the # as the beginning of a comment.




reference material: