diff --git a/dbm-services/mysql/db-priv/service/admin_password.go b/dbm-services/mysql/db-priv/service/admin_password.go index e68f001a84..fa7e0085f1 100644 --- a/dbm-services/mysql/db-priv/service/admin_password.go +++ b/dbm-services/mysql/db-priv/service/admin_password.go @@ -526,9 +526,9 @@ func (m *ModifyAdminUserPasswordPara) ModifyAdminPasswordForMysql( if !(*cluster.ClusterType == tendbcluster && role == machineTypeSpider) && MySQLVersionParse(mysqlVersion, "") >= MySQLVersionParse("8.0.0", "") { - userLocalhost = fmt.Sprintf("ALTER USER '%s'@'localhost' "+ + userLocalhost = fmt.Sprintf("ALTER USER IF EXISTS '%s'@'localhost' "+ "IDENTIFIED WITH mysql_native_password BY '%s'", m.UserName, psw) - userIp = fmt.Sprintf("ALTER USER '%s'@'%s' "+ + userIp = fmt.Sprintf("ALTER USER IF EXISTS '%s'@'%s' "+ "IDENTIFIED WITH mysql_native_password BY '%s'", m.UserName, address.Ip, psw) } sqls = append(sqls, userLocalhost, userIp, setBinlogOn, flushPriv)