Reset Root Password in MySQL ^8.*

  1. Add below code to the end of /etc/mysql/my.cnf file.
    [mysqld]
    skip-grant-tables
  2. Restart service:
    sudo systemctl restart mysql
  3. Login into mysql:
    sudo mysql -uroot
  4. Remove root password:
    UPDATE mysql.user SET authentication_string=null WHERE User='root'; FLUSH PRIVILEGES; exit;
  5. Comment below code at the end of /etc/mysql/my.cnf file by add # in front of each line.
    # [mysqld]
    # skip-grant-tables
  6. Restart service:
    sudo systemctl restart mysql
  7. Login into mysql:
    sudo mysql -uroot

Done! 🙂

Leave a Reply

Your email address will not be published. Required fields are marked *

5 × 4 =