self training/lin

centos 7 에서 mysql 8.0 패스워드 분실 시 root 패스워드 초기화

atthis 2024. 11. 14. 09:56


systemctl stop mysqld


systemctl set-environment MYSQLD_OPTS="--skip-grant-tables"


systemctl start mysqld


mysql -u root -p


UPDATE mysql.user SET authentication_string = null where user = 'root';
FLUSH PRIVILEGES;
quit


mysql -u root -p


alter user 'root'@'localhost' identified with caching_sha2_password by '새로운비밀번호';
FLUSH PRIVILEGES;
quit


systemctl stop mysqld
systemctl unset-environment MYSQLD_OPTS
systemctl start mysqld