You can reset the root password by starting the server with --skip-grant-tables and logging in without a password by running as the root user (or using sudo):
# service mysql stop # mysqld_safe --skip-grant-tables & $ mysql -u root
mysql> use mysql; mysql> update user set authentication_string=PASSWORD("YOUR-NEW-ROOT-PASSWORD") where User='root'; mysql> flush privileges; mysql> quit
# service mysql stop # service mysql start $ mysql -u root -p
Now you can log in as root with your new password.
In addition, you can find the request, reset the password in the /home/$USER/.mysql_history or /root/.mysql_history user, reset the password, but the above will always work.
Note: before MySQL 5.7, the column was called password and not authentication_string . Replace the line above
mysql> update user set password=PASSWORD("YOUR-NEW-ROOT-PASSWORD") where User='root';
Benjamin Manns Apr 15 2018-11-11T00: 00Z
source share