mysql 8.0重置用户密码skip-grant-tables

使用skip-grant-tables 模式


1. UPDATE mysql.user SET authentication_string=null WHERE User='root';
2. FLUSH PRIVILEGES;
3. mysql -u root
4. ALTER USER 'root'@'localhost' IDENTIFIED WITH caching_sha2_password BY 'yourpasswd';

非skip-grant-tables 模式


1. ALTER USER 'root'@'localhost' IDENTIFIED WITH caching_sha2_password BY 'yourpasswd';