天天看点

MySQL 8.0 修改root密码

step1:在my.ini配置文件中加入选项,以跳过密码验证:

skip-grant-tables

shared-memory:

step2:重启mysqld服务,以使新增配置项生效

step3:在命令行中使用mysql无密码方式登入:

> mysql -u root # 直接回车即可,如果跟了-p,出现输入密码时直接回车即可跳过

step4:将root密码置空

> update user set authentication_string = null where user = 'root';

> flush privileges;

step5:exit退出mysql

step6:将my.ini配置文件中step1中加入的选项注释掉,并重启mysqld服务

step7:mysql -u root进入mysql命令行模式,此处密码为空

step8:alter user 'root'@'localhost' identified with caching_sha2_password BY 'Alpha_123456';

如此,则root的密码被修改成功,可以重新登录了。

注意:新密码要求需包括大写字母、小写字母、特殊字符,缺一不可。

继续阅读