MySQL 5.7.26 Reset Root Password on Centos 6
I lost my root password with a mysql error, so I have to reset it, the server is Centos 6 and mysql 5.7.26, follow are the steps
{ 1. Open No Password Login Mode }
vi /etc/my.cnf
//find [mysqld], add "skip-grant-tables" under it as a new line
//save out
{ 2. Login without Password }
//restart mysql service
service mysqld restart
//yes only this one command
mysql
{ 3. Reset Root Password }
//select database
use mysql
//change pass
update user set password=password('YiiLibNewPass') where user='root';
FLUSH PRIVILEGES;
exit;
{ 4. Reset Everything }
remove skip-grant-tables from /etc/my.cnf
service mysqld restart
{ 5. Login with New Pass }
mysql -uroot -p
Leave Comment