1.修改MYSQL登录设置(vim /etc/my.cnf),添加一句:skip-grant-tables

[mysqld]
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
user=mysql
symbolic-links=0

skip-grant-tables

2.重启MYSQL :/etc/init.d/mysqld restart 或systemctl restart mariadb

3.登录并修改MYSQL的root密码

[root@linux-node ~]# mysql
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.1.73 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> 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> update user set password=password("000000") where user="root";
Query OK, 3 rows affected (0.00 sec)
Rows matched: 3 Changed: 3 Warnings: 0

mysql> flush privileges;
Query OK, 0 rows affected (0.01 sec)

4.编辑/etc/my.cnf配置文件,删除之前加的那一句"skip-grant-tables"

5.重启MYSQL:/etc/init.d/mysqld restart  或  systemctl restart mariadb

6.用root用户登录数据库

[root@linux-node ~]# mysql -uroot -p000000
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 3
Server version: 5.1.73 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.

转载于:https://www.cnblogs.com/liuhui-xzz/p/10322008.html

mysql忘记root密码怎么办,几个简单操作步骤找回mysql密码相关推荐

  1. linux mysql 忘记root密码_Linux MySQL忘记root密码解决方案

    在使用MySQL数据库时,由于某些原因长时间没有登陆MySQL,或者由于工作交接完成度不高,导致数据库root登陆密码忘记,如何解决? 一.更改my.cnf配置文件 1.用命令编辑/etc/my.cn ...

  2. MySQL忘记root密码不重启mysqld的方法

    MySQL忘记root密码不重启mysqld的方法 1.首先得有一个可以拥有修改权限的mysql数据库账号,当前的mysql实例账号(较低权限的账号,比如可以修改zabbix数据库)或者其他相同版本实 ...

  3. Linux下使用MySQL——忘记root密码及修改MySQL默认编码

    概述: 本博客不再对MySQL的语法进行讲解和说明,想了解或熟悉的朋友请自行百度或Google学习.本博客主要是针对MySQL除语法之外的总结,希望能够也能帮助到你. 1.CentOS6.x下MySQ ...

  4. mysql忘记root密码解决办法

    来源:http://jingyan.baidu.com/article/9c69d48f42166213c9024e02.html 通常在使用Mysql数据库时,如果长时间没有登陆,或者由于工作交接完 ...

  5. win上mysql忘记root密码_MySQL数据库之windows下mysql忘记root密码的解决方法

    本文主要向大家介绍了MySQL数据库之windows下mysql忘记root密码的解决方法 ,通过具体的内容向大家展现,希望对大家学习MySQL数据库有所帮助. 方法一: 1.在DOS窗口下输入net ...

  6. 附录:MySQL忘记root密码

    中小型规模网站集群架构:MySQL忘记root密码 : Ago linux运维群:93324526 前言 你忘记系统root密码的时候,你怎么解决的? 不就是single用户进行修改密码吗?这里原理是 ...

  7. Ubuntu下MySQL忘记root密码重置

    MySQL忘记root密码肿么办?-_-|||   这种情况虽然不是很常见,但是有时长时间没有登录系统,还真会忘记密码.这时候,如果您能以系统管理员权限登陆密码,那还是有救的.放大招,将其重置即可. ...

  8. Mysql 忘记root密码的完美解决方法

    一.更改my.cnf配置文件 1.用命令编辑/etc/my.cnf配置文件,即:vim /etc/my.cnf 或者 vi /etc/my.cnf 2.在[mysqld]下添加skip-grant-t ...

  9. Mac MySQL忘记root密码

    Mac MySQL忘记root密码 本文转载自Mac MySql忘记root密码! 刚刚在Mac上安装了下MySQL,但是发现不知道root密码是什么!所以,查找别人的博客,亲测可用,做个记录. 第一 ...

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

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

最新文章

  1. 扩展存储过程在哪里_青浦区智能仓储哪里有,一件代发1.9元全国_1.9元发全国-上海东臻仓储服务...
  2. python读取txt文件并写入excel-Python读取txt内容写入xls格式excel中的方法
  3. Spring整合Quartz定时发送邮件
  4. 系统输入输入出设计相关知识介绍
  5. react leaflet_如何使用Leaflet在React中轻松构建地图应用
  6. 在github上搭建hexo博客
  7. php分支结构有哪几种语句,PHP开发——分支结构
  8. mybatis 原理_了解Mybatis的工作原理吗
  9. 从婵媛的围脖上看到做产品的三个矛盾,思考ing......
  10. iOS安装CocoaPods详细过程
  11. python写字_用Python写书法作品,WOW!
  12. 智能工厂仓库管理系统软件有哪些哪家好呢
  13. Root Mi note lte with SuperSU without flashing TWRP Recovery permanently (by quqi99)
  14. python小车行走_[PYTHON系列教程]→控制小车
  15. Zygote启动及其作用
  16. LeetCode 164. 最大间距(桶排序+鸽笼原理)
  17. [Alpha] Scrum Meeting 2 - TEAM LESS ERROR
  18. 麦麦本重装win10无限自动关机,甚至pe进去后都自动关机问题
  19. spring的DI,IOP,AOC,Spring的简单介绍
  20. C语言实现的超详细的冒泡排序(附有详细代码)

热门文章

  1. 转载:迟到一年的面经,给准备做程序员的童鞋们
  2. UIApplication委托信息(多任务)
  3. 全网最全详解Windows CMD命令大全
  4. js检查关闭浏览器方法
  5. LW_OOPC介绍(转载)
  6. 37. 使用accumulate或者for_each进行区间统计
  7. git add多个文件_10个节省时间和改善工作流的Git技巧
  8. 三菱plc pwm指令_2020福建三菱PLCFX3GA60MT回收回收厂家回收气动元件回收
  9. docker下载安装mysql
  10. 计算机2级文档试题,计算机二级考试word操作题真题