Password Authentication Using mysql_config_editor in MySQL
You can store authentication credentials is an obfuscated login path file named .mylogin.cnf using “mysql_config_editor”. The file location is the “APPDATA%\MySQL directory on Windows and the current user’s home directory on non-Windows system.
mysql> CREATE USER 'auth_test'@'%' IDENTIFIED BY 'auth123';
mysql> GRANT SELECT ON *.* TO 'auth_test'@'%';
mysql> flush privileges;
# mysql_config_editor set --login-path=auth_test_login --user=auth_test --password
Enter password:
# ls -la .mylogin.cnf
-rw-------. 1 root root 132 Oct 14 19:06 .mylogin.cnf
# mysql_config_editor print --all
[auth_test_login]
user = "auth_test"
password = *****
# mysql --login-path=auth_test_login
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 17
Server version: 8.0.26 Source distribution
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>