You can’t view the hashed password; the only thing you can do is reset it!
Stop MySQL:
1 |
sudo service mysql stop |
or
1 |
$ sudo /usr/local/mysql/support-files/mysql.server stop |
Start it in safe mode:
1 |
$ sudo mysqld_safe --skip-grant-tables |
(above line is the whole command)
This will be an ongoing command until the process is finished so open another shell/terminal window, log in without a password:
1 2 3 |
$ mysql -u root mysql> UPDATE mysql.user SET Password=PASSWORD('password') WHERE User='root'; |
MySQL 5.7 and over:
1 2 |
mysql> use mysql; mysql> update user set authentication_string=password('password') where user='root'; |
Start MySQL:
1 |
sudo mysql start |
or
1 |
sudo /usr/local/mysql/support-files/mysql.server start |
Your new password is ‘password’.