If you’ve forgotten the root password for a MySQL server, but you know the system root, you can reset the MySQL root password pretty easily. Just remember to work quickly since the server is wide open until you finish working.
skip-grant-tables to the
[mysqld] section of /etc/my.cnf and restart the MySQL server.
mysql from the command line and use the following SQL statement:
UPDATE mysql.user SET Password=PASSWORD('newpwd') WHERE User='root';<br />
skip-grant-tables from /etc/my.cnf and leave the server running. There’s no need to restart it.