Tuesday, January 19, 2021

[MacOS][Resolved] mysql mac forgot root password

 I have many years haven't use local MySQL and can't found back the password, I don't know what inside and found most method exist are for ppl who at least can login mysql with non-root account. 

However, I forget ALL username and password !!

Here is a method works for me but need delete existing database, but nvm, i don't care what inside:


Command

brew services stop mysql
pkill mysqld
rm -rf /usr/local/var/mysql/ # NOTE: this will delete your existing database!!!
brew postinstall mysql
brew services restart mysql
mysql -u root

Result:


Reference:

https://gist.github.com/zubaer-ahammed/c81c9a0e37adc1cb9a6cdc61c4190f52

No comments :

Post a Comment