mac 기준으로 설명
1. mysql을 멈춘다.
mysql.server stop
2. mysql을 skip-grant-tables 모드로 재실행한다.
mysql.server start --skip-grant-tables
3. root 유저의 비밀번호를 null로 바꿔준다.
UPDATE mysql.user SET authentication_string=null WHERE User='root';
FLUSH PRIVILEGES;
exit;
4. 다시 root 계정으로 로그인한다. 비밀번호를 null로 바꿨기 때문에 패스워드 없이 로그인이 가능하다.
mysql -u root
5. 비밀번호를 변경해준다.
ALTER USER 'root'@'localhost' IDENTIFIED WITH caching_sha2_password BY 'newPassword';