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 Replication Switchover: Step-by-Step Guide

How to create database manually in oracle 11g R2

How To Install and Configure Innodb Cluster /shell/Router