忘记MYSQL管理员密码如root用户密码,可以按照以下方式来修改
STEP1: 停止MySQL服务
ps -ef | grep -v 'grep' | grep 'mysqld' | awk '{print $2}' | xargs kill -9
STEP2: 以忽略权限方式启动MYSQL服务
/export/servers/mysql/bin/mysqld --skip-grant-tables --explicit_defaults_for_timestamp --user=mysql &
STEP3: 更新管理员密码
## MySQL5.6版本更新密码
update mysql.user set password=password("abc@123.com") where user="root";
## MySQL5.7版本更新密码
update mysql.user set authentication_string=password("new_pass") where user="root";
## 刷新权限
flush privileges;
STEP4: 停止MySQL服务,重新正常启动
ps -ef | grep -v 'grep' | grep 'mysqld' | awk '{print $2}' | xargs kill -9
/export/servers/mysql/bin/mysqld_safe --defaults-file=/export/servers/mysql/etc/my.cnf &