mysql centos 修改密码_centos mysql忘记密码,修改密码

centos mysql忘记密码,修改密码

1.修改配置文件my.cnf

[root@localhost ~]# vi /etc/my.cnf

找到mysqld在之后添加

skip-grant-tables

保存退出

2. 重启mysql服务(必须重启后才能不需要密码进入)

systemctl restart mysqld

3.直接登陆mysql而不需要密码

mysql -u root (直接点击回车)

4.在mysql中输入

use mysql;

update user set authentication_string='admin1234' where user='root';

显示下面信息

Query OK, 2 rows affected (0.00 sec)

Rows matched: 2 Changed: 2 Warnings: 0

5.执行 flush privileges;

6.退出mysql ,到my.cnf中把开始添加的skip-grant-tables去掉

7.重启mysql服务 systemctl restart mysqld

8.重新进入 mysql -u root -p

用修改的密码还是进入不了

[root@iZwz9env7nl3mi5mxx7yp6Z ~]# mysql -u root -p

Enter password:

ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值