It will happen from time to time, that you're on alien machine and have to brutally update things in db without knowing credentials. Example is for root (quite secure candidate to change because it shouldn't be used in app 🙂 ) but will work for any user.
- shutdown db
service mysql stop
- create text file with command like this (update user accordingly) ex. in /tmp/pwchange.txt
SET PASSWORD FOR 'root'@'localhost' = PASSWORD('HereYourNewPassword');
sometimes you may require to point configuration file ex.
- wait until it loads and kill mysql (ex. Ctrl+C / kill / etc)
- start mysql
service mysql start
- delete file with password
rm -f /tmp/pwchange.txt
You should be able to login with updated password.