Recover MySQL 5.7 root Password in Redhat/CentOS 7

step.1. stop mysqld service

systemctl stop mysqld 

step.2.set the mysql enviroment option

systemctl set-environment MYSQLD_OPTS="--skip-grant-tables"

step.3 start mysqld service using the option just you set

systemctl start mysqld

step .4. login as root

mysql -u root 

step.5.update the root user password using this command

mysql> UPDATE mysql.user SET authentication_string = PASSWORD('YourNewPassword')
-> WHERE User = 'root' AND Host = 'localhost';
mysql> FLUSH PRIVILEGES;
mysql> quit

step.6.stop mysqld

systemctl stop mysqld

step.7. unset the mysql enviroment variable 

systemctl unset-environment MYSQLD_OPTS

step.8.start mysqld service normally

systemctl start mysqld

step.9.

mysql -u root -p





Comments

Popular posts from this blog

MySQL Point in Time Recovery: How To Configure And How Does it Work?

MySQL Replication Switchover: Step-by-Step Guide

Mysql Commercial Mysqlbackup:How to take Differential or Incremental Backup and resotre using mysqlbackup utility in mysql 8.0.37 enterprise edition