mysql 6安装当前密码_Centos6.7下mysql5.5.32忘记数据库的root密码怎么破?

Centos6.7下mysql5.5.32忘记数据库的root密码怎么破?

有一天你兴高采烈的准备去连接mysql服务器时间,发现如下一幕,你该怎么办呢?

[root@abao ~]# mysql -uroot -p

Enter password:

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

不怕,不怕,ABAO阿宝来帮你解决这个问题哈,步骤如下:

1、查看当前安装的mysql版本:

[root@abao ~]# mysql -V

mysql  Ver 14.14 Distrib 5.5.32, for Linux (x86_64) using readline 5.1

2、停止mysql服务:

[root@abao ~]# service mysqld stop

Shutting down MySQL. SUCCESS!

3、进入到skip-grant-tables模式:

[root@abao ~]# mysqld_safe --skip-grant-tables

170411 00:35:07 mysqld_safe Logging to '/data/abao67.err'.

170411 00:35:07 mysqld_safe Starting mysqld daemon with databases from /data

此时新打开一个窗口

现在就不需要密码就可以进入mysql了:

[root@abao ~]# mysql

进入mysql系统数据库:

mysql> use mysql

修改root账户密码:

mysql> update user set password=password("12345") where user="root";

刷新权限:

mysql> flush privileges;

mysql> exit

停止mysql进程:

[1]+ Stopped mysqld_safe --skip-grant-tables

启动mysql:

[root@abao ~]# service mysqld start

4、使用刚才修改的密码进入mysql:

[root@abao ~]# mysql -uroot -p12345

Welcome to the MySQL monitor.  Commands end with ; or \g.

Your MySQL connection id is 1

Server version: 5.5.32-log Source distribution

Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its

affiliates. Other names may be trademarks of their respective

owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> show databases;

+---------------------+

| Database            |

+---------------------+

| information_schema  |

| #mysql50#lost+found |

| mysql               |

| performance_schema  |

| test                |

+---------------------+

5 rows in set (0.01 sec)

恭喜你,修改完成啦!

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值