How to reset mysql root password in RedHat

My friend posted about reseting mysql root password long time ago. It still works but you have to know how to change root password properly. Since I have to do it by myself, I will explain more detail in this post.

  1. Add skip-grant-tables in section [mysqld] in /etc/my.cnf
  2. Restart mysqld by service mysqld restart
  3. Change password using below query.

    update mysql.user set password=password('new password') where user='root';
    
  4. Remove skip-grant-tables from /etc/my.cnf

  5. Restart mysqld again

Tags: ,

Post new comment