使用mysql_config_editor安全地保存和管理登录凭据

当我们希望通过MySQL客户端免密访问不同的数据源时,推荐使用mysql_config_editor工具。

实践案例如下:

[xuej@localhost ~]$ mysql_config_editor set --login-path=order_db --host=rm-uf63iqp0u65o69qf6.mysql.rds.aliyuncs.com --user=user_sale_rw --password
Enter password: 
[xuej@localhost ~]$ mysql --login-path=order_db
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 1554067
Server version: 5.7.32-log Source distribution

Copyright (c) 2000, 2022, 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> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| sale_service_sit   |
+--------------------+
3 rows in set (0.02 sec)