Recently, I tried to log into mysql as the root user but it resulted in the error message
mySQL ERROR 1045 (28000): Access denied for user 'root'@'localhost
So, I spent hours searching for a solution on the internet but sadly, many other users like me had the same problem as I had, but without a solution. But, finally I found out a solution to it.
Its very simple. Just type in the following two line command into the terminal :
sudo service mysql stop
sudo mysqld --skip-grant-tables
Doing this as the root user, you will be able to skip all the grant tables and then you can login (hopefully without a password).
The above command may take a few minutes to be executed. After that,you can login as the root user by using the command
mysql -u root
Hope it helped. Note that, this may not work in platforms other than linux. The command to do this may vary.