diff --git a/tool/tsh/common/db.go b/tool/tsh/common/db.go index 738914fa86e4e..6bb7e75cf6cc1 100644 --- a/tool/tsh/common/db.go +++ b/tool/tsh/common/db.go @@ -653,7 +653,6 @@ func maybeStartLocalProxy(ctx context.Context, cf *CLIConf, host := "localhost" cmdOpts := []dbcmd.ConnectCommandFunc{ dbcmd.WithLocalProxy(host, addr.Port(0), profile.CACertPathForCluster(rootClusterName)), - dbcmd.WithGetDatabaseFunc(dbInfo.getDatabaseForDBCmd), } if requires.tunnel { cmdOpts = append(cmdOpts, dbcmd.WithNoTLS()) @@ -777,7 +776,10 @@ func onDatabaseConnect(cf *CLIConf) error { if err != nil { return trace.Wrap(err) } - opts = append(opts, dbcmd.WithLogger(log)) + opts = append(opts, + dbcmd.WithLogger(log), + dbcmd.WithGetDatabaseFunc(dbInfo.getDatabaseForDBCmd), + ) if opts, err = maybeAddDBUserPassword(cf, tc, dbInfo, opts); err != nil { return trace.Wrap(err)