Reset mysql password

Reset mysql password

First try to see if you can login to mysql as root.
ssh to root user, or su root from AD login.

      mysql

If you get an error similar to:

ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)

Then the password is likely incorrect. You can sometimes check and see what the password is in /root/.mysql
but almost always (It should be always) It's encrypted.

Now stop the mysql process this can be one of a few slightly different commands:

      systemctl stop mysql
      systemctl stop mysqld
      service mysql stop
      service mysqld stop

Once you get a confirmation the service is stopped, run

      mysqld_safe --skip-grant-tables &

This will put a mysql process without needing a password in the background. Then

      mysql

You should now be logged in as root.
Now run the commands to change the password, ensure you change "mynewpassword" with your password.
You can run one command at a time

      use mysql;
      update user set authentication_string=PASSWORD("mynewpassword") where User='root';
      flush privileges;
      quit

Then restart the mysql process again (Remember the differences in the commands from before)

      service mysql stop && service mysql start

The password should now be changed!
Test it with:

mysql -u root -p "mynewpassword"