Tiup client, dsn does not support saving passwords

Note:
This topic has been translated from a Chinese forum by GPT and might contain errors.

Original topic: tiup client,dsn 不支持保存密码

| username: ShawnYan

[TiDB Usage Environment] Production Environment / Testing / Poc
[TiDB Version]
[Reproduction Path] What operations were performed to encounter the issue
[Encountered Issue: Issue Phenomenon and Impact]
[Resource Configuration] Go to TiDB Dashboard - Cluster Info - Hosts and take a screenshot of this page
[Attachment: Screenshot/Logs/Monitoring]

tiup client uses DSN to connect to the TiDB server, but initially, there is only the root user. After changing the root user’s password, the DSN file does not update automatically, and it must be manually modified to connect successfully.

[root@shawnyan 7.1]# cat dsn 
mysql://root@192.168.8.171:4000[root@shawnyan 7.1]# 
[root@shawnyan 7.1]# tiup client
tiup is checking updates for component client ...
Starting component `client`: /root/.tiup/components/client/v1.12.5/tiup-client
Error: can't open connection to mysql://root@192.168.8.171:4000: mysql: 1045: Access denied for user 'root'@'192.168.8.171' (using password: NO)

[root@shawnyan 7.1]# vi dsn 
[root@shawnyan 7.1]# cat dsn 
mysql://root:1@192.168.8.171:4000
[root@shawnyan 7.1]# tiup client
tiup is checking updates for component client ...
Starting component `client`: /root/.tiup/components/client/v1.12.5/tiup-client
Connected with driver mysql (5.7.25-TiDB-v7.1.0)
Type "help" for help.

my:root@192.168.8.171:4000=> select tidb_version();
                      tidb_version()                       
-----------------------------------------------------------
 Release Version: v7.1.0                                  +
 Edition: Community                                       +
 Git Commit Hash: 635a4362235e8a3c0043542e629532e3c7bb2756+
 Git Branch: heads/refs/tags/v7.1.0                       +
 UTC Build Time: 2023-05-30 10:58:57                      +
 GoVersion: go1.20.3                                      +
 Race Enabled: false                                      +
 TiKV Min Version: 6.2.0-alpha                            +
 Check Table Before Drop: false                           +
 Store: tikv 
(1 row)

my:root@192.168.8.171:4000=>  

	for _, db := range dbs {
		dsn = append(dsn, fmt.Sprintf("mysql://root@%s", db.Addr()))
| username: wangkk2024 | Original post link

Bump.