忘记root密码

如果不小心忘记了root密码,那么mysql就不能再登录了,这时就要重置root密码才行。通过下面的步骤,我们可以重新设置root密码。

1、退出mysql

[root@localhost src]# service mysqld stop

停止mysqld:[确定]

[root@localhost src]#

2、进入sql安全模式,命令“/usr/bin/mysqld_safe --skip-grant-table &”

[root@localhost src]#/usr/bin/mysqld_safe --skip-grant-table &

[1] 6332

[root@localhost src]# 180814 10:10:00 mysqld_safe Logging to '/var/log/mysqld.log'.

180814 10:10:00 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql

3、无密码方式登录,命令“mysql –u root”

[root@localhost src]# mysql -u root

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

Your MySQL connection id is 1

Server version: 5.1.71 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>

4、使用mysql,命令“use mysql;”

mysql> use mysql;

Reading table information for completion of table and column names

You can turn off this feature to get a quicker startup with -A

Database changed

mysql>

5、重设root密码,命令“update user set password=password (“密码”) where user=’root’”

mysql> update user set password=password('123456') where user='root';

Query OK, 3 rows affected (0.00 sec)

Rows matched: 3  Changed: 3  Warnings: 0

mysql>

6、刷新

mysql> flush privileges;

Query OK, 0 rows affected (0.00 sec)

7、退出,重新登录

[root@localhost src]# mysql -u root -p

Enter password:        //这里输入新密码

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

Your MySQL connection id is 2

Sever version: 5.1.71 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>

mysql服务器万能密码_Linux服务器---mysql忘记root密码相关推荐

  1. debian linux忘记密码,debian ubuntu linux 忘记root密码的重置方法

    在前一章,讲了在 redhat/CentOS 等系统中,忘记 root 密码的重置方法,是修改 grub 里的 kernel 那一行,使其进入单用户,然后修改密码,可以这种方法,在 ubuntu 以及 ...

  2. linux 不知道root密码怎么办,linux下忘记root密码怎么办

    在linux系统操作中,为了系统的安全,会给系统中的root账户设置密码,那么忘记密码是时常发生的事情.如果忘记了root的密码该怎么办呢?下面秋天网 Qiutian.ZqNF.Com小编就给大家介绍 ...

  3. red hat linux忘记root密码,Red Hat Linux忘记root密码的解决办法

    Red Hat Linux忘记root密码的解决办法 Red Hat Linux忘记root密码的解决办法 1在出现系统选择界面时,在Red Hat Linux的选项上按"e"键, ...

  4. linux bios密码设置时间,linux忘记root密码及时间设定

    文章来自网上整理还有个人总结 redhat 5恢复root用户的密码 开机按e进入编辑模式,选择内核把 kernel /vmlinuz-2.6.18-53.el5 ro root=/dev/VolGr ...

  5. linux7.4 root密码,[RHEL 7.4] 忘记root密码,普通用户又没有sudo权限,怎么办?

    依云 说:在内核命令行上加 init=/bin/bash 然后进去改好密码,sync 之后长按电源键(或者拔电源)重启. 或者用 live 系统 chroot 进去改密码. 不好意思,我还是相当新的新 ...

  6. mysql忘记root密码及修改密码

    方法1: 用SET PASSWORD命令  首先登录MySQL.  格式:mysql> set password for 用户名@localhost = password('新密码');  例子 ...

  7. kali linux忘记开机密码,kali linux 忘记root密码重置办法

    有段时间没用kali linux 的,加上最近装的系统有比较多,系统root的密码忘掉了,真是麻烦啊.之前在网上看到的一些方法尝试后没进的去,可能是因为不同的linux 不一样吧. 如果因为忘记密码而 ...

  8. RedFlag Linux忘记root密码解决办法

    转于lee的http://hi.baidu.com/maozilee/item/12a62a76f371df2bd7a89c5d RedFlag Linux忘记root密码解决办法 Linux忘记ro ...

  9. linux mysql root免密_Linux下MySQL忘记root密码的完美解决方法

    在使用MySQL数据库时,由于某些原因长时间没有登陆MySQL,或者由于工作交接完成度不高,导致数据库root登陆密码忘记,本文给大家介绍一种当忘记MySQL root密码时的解决办法,亲测有效. 首 ...

最新文章

  1. Shell---判断(if)和分支(case)
  2. HDU1899 Sum the K-th's(树状数组)
  3. python爬虫 发送定时气象预报
  4. oschina android版源码中的颜色值
  5. ARM 内核移植中常见的错误
  6. Linux 网络及IP概述
  7. 【转】智能音箱技术概览
  8. java java编码_Java编码约定被认为是有害的
  9. 23中设计模式之抽象工厂模式
  10. 使用jaxb根据xsd逆向生成java代码
  11. django-单表的增删改查-用户部门表
  12. postgresql interval 字段拼接
  13. 修改表结构的执行效率
  14. 《软件工程》网上书店项目需求规格说明书
  15. 程序员修炼之道——读序
  16. ubuntu18单机部署k8s(v1.14.1)
  17. 手机屏幕如何投屏到电脑显示器上?
  18. riscv-gnu-toolchain工具链的安装
  19. 如何给sqlserver 的表添加注释
  20. 国医大师王绵之:汤药煎服经验谈

热门文章

  1. bzoj4916: 神犇和蒟蒻(杜教筛)
  2. Vegas怎么做闪屏特效,闪屏特效制作教程
  3. HDR in OpenGL
  4. Efficientdet源码详解
  5. 2012-2020年全国大学生数学建模竞赛的国家一等奖论文
  6. web和应用服务器的区别
  7. xp无法搜索计算机名,雨林木风xp系统无法搜索到工作组计算机怎么办
  8. 黑莓手机的一些小技巧
  9. 视觉感知特性【2】一些视觉感知因子
  10. 基于matlab的数字下变频器的设计与仿真应用,基于matlab的简单数字下变频器的设计...