How To : Reset MySQL Root Password

  Database

First stop the mysql service

[cc lang=”bash”]service mysqld stop
or
systemctl mysqld stop[/cc]

Start mysql with safe mode
[cc lang=”bash”]sudo mysqld_safe –skip-grant-tables[/cc]

Log into MySQL as root:
[cc lang=”bash”]mysql -u root[/cc]

Change to the mysql database, which handles the settings for MySQL itself:
[cc lang=”bash”]use mysql;[/cc]

Update the password for the root user:
[cc lang=”bash”]update user set password=PASSWORD(“newpassword”) where User=’root’;[/cc]

Refresh the MySQL user privileges:
[cc lang=”bash”]flush privileges;[/cc]

Exit MySQL:
[cc lang=”bash”]exit[/cc]

Restart mysql back and retry to login with new password
[cc lang=”bash”]mysql -u root -p[/cc]