ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)
-
Stop MySQL service (in my case, is installed with brew)
brew services stop mysql
-
Start MySQL safe
mysqld_safe --skip-grant-tables
-
Connect to MySQL with
mysql
-
Execute next scripts ↓
Pass: for your password, use: MySQL < 8
SELECT PASSWORD('mypass');
MySQL >= 8
SELECT CONCAT('*', UPPER(SHA1(UNHEX(SHA1('mypass')))));
USE mysql; insert into `user` VALUES('%','root','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','','0x','0x','0x',0,0,0,0,'mysql_native_password','*DA7A8D7CA47235D5970C15CB43228E28671B9872','N','2021-09-27 14:24:45',NULL,'N','Y','Y',NULL,NULL,NULL,NULL);
-
Stop MySQL safe
killall mysqld
-
Start MySQL service
brew services start mysql
-
All is ready. To enjoy mysql again