Step1: Stopping the MySQL service by using this command systemctl command:

#sudo systemctl stop mysql

Step2: Now, we need to restart the MySQL service.

#sudo mysqld_safe --skip-grant-tables

Step3: We have able to connect to the MySQL server as root, without specifying a password.

#mysql -u root

Step4: Now, reset the root password, but first flush the privileges to reload the grants.

mysql> FLUSH PRIVILEGES;
mysql> use mysql;
mysql> update user set plugin="mysql_native_password" where User='root';
mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'new_password_here';
mysql> FLUSH PRIVILEGES;
mysql> quit;

Step5: Finally, shut down the MySQL service and start it back up.

#sudo systemctl restart mysql

Leave a Reply

This website stores cookies on your computer. These cookies are used to provide a more personalized experience and to track your whereabouts around our website in compliance with the European General Data Protection Regulation. If you decide to to opt-out of any future tracking, a cookie will be setup in your browser to remember this choice for one year.

Accept or Deny