在linux平台下使用mysql过程中忘记了root密码,对于运维和DBA来讲都是一件头疼的事情,下面来讲解下怎么进行重置mysql数据库root 密码:

1、首先停止mysql服务进程:

1 service mysqld stop

然后编辑mysql的配置文件my.cnf

1 vim /etc/my.cnf

找到 [mysqld]这个模块:

在最后面添加一段代码

1 skip-grant-tables ##忽略mysql权限问题,直接登录

然后保存 :wq!退出

启动mysql服务:

1 service mysqld start

直接进入mysql数据库:

1 Starting MySQL. SUCCESS!

2 [root@web1 ~]# mysql

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

4 Your MySQL connection id is 1

5 Server version: 5.6.34 Source distribution

6

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

8

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

10 affiliates. Other names may be trademarks of their respective

11 owners.

12

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

14

15 mysql>

使用mysql表,然后进行修改mysql的root密码:

1 mysql> use mysql; ##使用mysql数据库

2 Reading table information for completion of table and column names

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

4

5 Database changed

6 mysql> update user set password=password("123456") where user="root";##更新密码

7 Query OK, 4 rows affected (0.00 sec)

8 Rows matched: 4 Changed: 4 Warnings: 0

9

10 mysql> flush privileges;##刷新权限

11 Query OK, 0 rows affected (0.00 sec)

1 [root@web1 ~]# ps -ef |grep mysql ##显示mysql现有的进程

2 root 56407 1 0 17:50 pts/0 00:00:00 /bin/sh /usr/local/mysql/bin/mysqld_safe --datadir=/data/mysql --pid-file=/data/mysql/web1.pid

3 mysql 56533 56407 0 17:50 pts/0 00:00:00 /usr/local/mysql/bin/mysqld --basedir=/usr/local/mysql --datadir=/data/mysql --plugin-dir=/usr/local/mysql/lib/plugin --user=mysql --log-error=/data/mysql/web1.err --pid-file=/data/mysql/web1.pid

4 root 56560 1737 0 17:55 pts/0 00:00:00 grep mysql

5 [root@web1 ~]# killall mysqld ##删除mysql现有进程

6 [root@web1 ~]# ps -ef |grep mysql

7 root 56566 1737 0 17:56 pts/0 00:00:00 grep mysql

8 [root@web1 ~]# service mysqld start ##重新启动mysql服务

9 Starting MySQL. SUCCESS!

10 [root@web1 ~]# mysql -uroot -p ##使用新密码登录

11 Enter password:

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

13 Your MySQL connection id is 1

14 Server version: 5.6.34 Source distribution

15

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

17

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

19 affiliates. Other names may be trademarks of their respective

20 owners.

21

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

23

24 mysql>

注意:先把mysql服务进程关闭,把添加过的跳过验证信息删除,要不然对数据库安全威胁太大,

5.7版本

linux mysql忘记root_linux下mysql-5.6忘记root密码,重置root密码详细过程相关推荐

  1. mysql5.7.17.zip教程,Mysql学习win10下mysql 5.7.17 zip压缩包版安装教程

    搜索热词 <MysqL学习win10下MysqL 5.7.17 zip压缩包版安装教程>要点: 本文介绍了MysqL学习win10下MysqL 5.7.17 zip压缩包版安装教程,希望对 ...

  2. ubuntu删除安装的mysql数据库_Ubuntu下MySQL数据库安装与配置与卸载

    安装: sudo apt-get install mysql-server mysql-client 一旦安装完成,MySQL 服务器应该自动启动.您可以在终端提示符后运行以下命令来检查 MySQL ...

  3. linux mysql删除root_Linux下误删MySQL的root用户解决方法

    开始对Linux界面不熟悉,可能由于不小心,把root误删了,怎么办? 1. # killall MySQLd    干掉所有mysql进程 2. # mysqld_safe --skip-grant ...

  4. 忘记linux里mysql账号密码忘记_Linux下MySQL忘记root用户密码

    今天在接收一台MySQL服务器的时候发现忘记MySQL的root用户的密码,查找资料发了各种文档里面也没有root用户密码,因此需要修改root用户密码. 首先确认服务器出于安全的状态,也就是没有人能 ...

  5. linux mysql 事务_linux下mysql Insert update delete 事务 用户管理

    linux下mysql Insert update delete  事务 用户管理 1.INSERT插入语句格式: INSERT INTO tb_name (字段1, 字段2, ...) VALUES ...

  6. linux下mysql授权_linux下mysql命令(用户授权、数据导入导出)

    1,linux下启动mysql的命令: 复制代码 代码示例: mysqladmin start /ect/init.d/mysql start (前面为mysql的安装路径) 2,linux下重启my ...

  7. linux重新安装mysql步骤_Linux下MySQL安装及相关操作过程

    一.安装MySQL数据库,但是前提是已经安好Linux系统,我使用的是Red hat desktop 6.0 SP1,系统盘的Tools里面有相应的软件,为5.0系列,但经测试无法使用,不能正常运行, ...

  8. linux安装mysql字符_Linux下MySQL的彻底卸载和安装配置字符集

    前言: Linux环境下MySQL的安装和配置在网上已经有很多教程了.之所以写这篇文章是因为在配置字符集的时候找了网上的一些教程发现并不能用导致折腾了一阵子.下面的教程均是亲自实践. MySQL的彻底 ...

  9. linux删除mysql临时文件_linux下mysql自动备份数据库与自动删除临时文件_MySQL

    bitsCN.com linux下mysql自动备份数据库与自动删除临时文件 一.每日23:00自动删除临时文件 首先查看一下crontab的任务列表:crontab -l然后新建:crontab - ...

最新文章

  1. UML学生成绩管理系统需求分析
  2. IDEA报错:Loading class `com.mysql.jdbc.Driver‘. This is deprecated. The new driver class is `com.mysql
  3. “管理”解读——浅谈国内IT服务管理产品标准建立的必要性(之一)
  4. tutte定理证明hall定理_人教社课本现低级错误?“爱因斯坦用相对论证明勾股定理”...
  5. hello python的代码,python基础教程之Hello World!
  6. SharePoint 调查列表的自定义错误页面
  7. form表单 vue 拖拽_vue实现可视化可拖放的自定义表单(代码示例)
  8. 阿里云智能图像识别服务发布
  9. Java和python哪个好,学哪个有用。
  10. 蚂蚁笔记 linux安装教程,简年14:蚂蚁笔记(Leanote)快速部署指南
  11. 海康摄像头SDK跨平台通用解决方案
  12. ionic加载html5,ionic 加载动画
  13. 【FPGA】安路FPGA下载器驱动安装教程
  14. Error: Rule can only have one resource source (provided resource and test + include + exclude)...
  15. CentOS Install Passenger for ROR
  16. 派工单系统 源码_青鸟报修云酒店设备报修管理系统
  17. 防疫与复工同行,长沙望城进入“双统筹”的关键时刻
  18. java 内联_Java内联类初探
  19. java中HelloWorld原来还可以这样玩
  20. 决策树决策算法ID3算法、改进算法C4.5算法和CART算法代码实现

热门文章

  1. linux看php安装路径,linux下查找php安装路径的方法是什么
  2. eclipse mysql 线程池_JAVA5线程池使用
  3. java 基本类型 object_Java常用类-Object类
  4. mysql 5.6 cmake 安装_Cmake MySQL5.6 编译安装
  5. oracle数据库从关闭到启动,Oracle数据库的启动和关闭详细过程
  6. 串口下载器rts线不接可以吗_【单片机自学】1.单片机的开发环境及下载过程教程...
  7. docker pull时候太慢卡死
  8. 【Python】functools.wraps定义函数装饰器
  9. html5 drap 文件夹,带有显示ID的Html5 drap and drop问题
  10. java 暂停多线程_关于java中多线程的暂停