macOS的mysql8.0.19忘记密码之跳过权限+重设密码

    技术2022-07-10  167

    cd mysql的bin目录下  (cd /usr/local/bin/)mysqld -nt --skip-grant-tables (跳过权限)重新打开一个CMD命令行窗口,输入mysql -u root -p,使用空密码的方式登录MySQL(不用输入密码,直接按回车)UPDATE mysql.user set authentication_string = '' WHERE User = "root" and Host = "localhost";(先设置为空串)exit关闭步骤1的mysqld -nt --skip-grant-tables服务,用ps -ef | grep mysql,然后 kill -9 进程号重启mysql服务修改密码: ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'root123456';

    flush privileges

     

    说明:

    ERROR:Your password does not satisfy the current policy requirements. 说明密码过于简单用字母加数字组合试下,或者修改validate_password_policy,可参考:https://hoststud.com/resources/resolved-mysql-error-your-password-does-not-satisfy-the-current-policy-requirements.464/

    brew services start mysql(后台启动mysql) mysql.server start    mysql.server stop    mysql.server restart(不在后台运行)

    参考:

    https://www.cnblogs.com/mumue/p/3816185.htmlhttps://blog.csdn.net/csdnzhiwang/article/details/103375413

     

     

    Processed: 0.011, SQL: 9