mysql5.7.23系列修改root默认密码

操作系统为centos7 64

1、修改 /etc/my.cnf,在 [mysqld] 小节下添加一行:skip-grant-tables=1

这一行配置让 mysqld 启动时不对密码进行验证

2、重启 mysqld 服务:systemctl restart mysqld

3、使用 root 用户登录到 mysql:mysql -u root 

修改密码的方法:

mysql> alter user root@localhost identified by 'tyzZ001!';
Query OK, 0 rows affected (0.00 sec)

新修改的密码中 必须包含 大小写字母数字及符号

5、退出 mysql,编辑 /etc/my.cnf 文件,删除 skip-grant-tables=1 的内容

6、重启 mysqld 服务,再用新密码登录即可

在第三步也可以用update mysql.user set authentication_string=password('new_password') where user='root' and Host ='localhost';设置密码

猜你喜欢

转载自blog.csdn.net/lap2004/article/details/82291953
今日推荐