Mysql数据库忘记密码找回

a 停止mysql服务

/etc/init.d/mysql stop

b 使用--skip-grant-tables启动mysql,忽略授权登录验证

mysqld_safe --skip-grant-tables --user=mysql &

mysql -u root -p                   ---登录时以空密码登录

c 登录mysql,修root密码

mysql

update mysql.user set password=password("123")  where user='root' and host='localhost'

flush privileges;

d 关闭重启mysql

/etc/init.d/mysqld stop

/etc/init.d/mysqld start

演示

[root@db02 ~]# mysqld_safe --skip-grant-tables --user=mysql &

[] 1390

[root@db02 ~]# 170428 23:26:25 mysqld_safe Logging to '/application/mysql-5.6.34/data/db02.err'.

170428 23:26:25 mysqld_safe Starting mysqld daemon with databases from /application/mysql-5.6.34/data

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

Enter password:

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

Your MySQL connection id is 1

Server version: 5.6.34 Source distribution

Copyright (c) 2000, 2016, 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> update mysql.user set password=password("123")  where user='root' and host='localhost';

Query OK, 1 row affected (0.00 sec)

Rows matched: 1  Changed: 1  Warnings: 0

mysql>

mysql> flush privileges;

Query OK, 0 rows affected (0.00 sec)

mysql> quit

[root@db02 ~]# /etc/init.d/mysqld stop

[root@db02 ~]# /etc/init.d/mysqld start

[root@db02 ~]# mysql -uroot -p123

Warning: Using a password on the command line interface can be insecure.

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

Your MySQL connection id is 1

Server version: 5.6.34 Source distribution

Copyright (c) 2000, 2016, 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数据库忘记密码找回方法的更多相关文章

  1. centos系统mysql数据库忘记密码重置方法(ERROR 1045 28000 Access denied...)

    当mysql的密码错误的时候,就会报如下这样的错误信息 解决方法如下: 首先输入mysqld_safe --skip-grant-tables 然后停止mysql服务,输入service mysqld ...

  2. mysql数据库忘记密码时如何修改(一)

    方法/步骤 打开mysql.exe和mysqld.exe所在的文件夹,复制路径地址 打开cmd命令提示符,进入上一步mysql.exe所在的文件夹. 输入命令  mysqld --skip-grant ...

  3. mysql数据库忘记密码时如何修改(转)

    当我们忘记mysql数据库密码时我们就无法正常进入数据库,也就无法修改密码,那么这时该怎么修改密码呢,这里教大家一个简单常用修改密码的方式. (如果图简单快速修改密码的话,直接跳过查询步骤,依照图上执 ...

  4. Ubuntu server 安装的mysql数据库忘记密码的解决方法

    客户端连接时报错MySQL数据库出现:Error 1045错误时,就表明输入的用户名或密码错误被拒绝访问了. 解决办法可以分为以下几步: 1.修改mysql配置文件,使得可以无密码登录mysql su ...

  5. Centos6.8忘记MySQL数据库root密码解决方法

    一.更改MySQL配置文件my.cnf,跳过密码验证. 编辑配置文件/etc/my.cnf文件,在[mysqld]下面添加skip-grant-tables,保存退出.如图: vim /etc/my. ...

  6. Linux数据库忘记密码-修改方法

    一.拥有原来的myql的root的密码: 方法一:在mysql系统外,使用mysqladmin# mysqladmin -u root -p password "test123"E ...

  7. MySQL数据库忘记密码怎么办?

    忘记MySQL数据库密码就进不去数据库,也就无法修改密码,解决方法如下: 1:打开cmd命令符,先关闭正在运行的数据库,输入如下命令: 2:打开mysql.exe和mysqld.exe所在的文件夹,复 ...

  8. MYSQL数据库忘记密码

    1.忘记密码解决办法 Windows下的实际操作如下 1.关闭正在运行的MySQL. 2.打开DOS窗口,转到mysql\bin目录. 3.输入mysqld --skip-grant-tables回车 ...

  9. MySQL数据库忘记密码如何重新设置?

    前 言当我们忘记了MySQL数据库密码后,该如何重新进行设置? 操作步骤步骤1:cmd打开命名窗口 步骤2:关闭正在运行的MySQL服务(命令:net stop mysql)(如果:此时MySQL正在 ...

随机推荐

  1. Webstorm常用快捷键备忘

    WebStorm 是jetbrains公司旗下一款JavaScript 开发工具.被广大中国JS开发者誉为“Web前端开发神器”.“最强大的HTML5编辑器”.“最智能的JavaSscript IDE ...

  2. centos7安装google-chrome和chromedriver

    1.root用户下进入到etc/yum.repos.d目录下  [root@f7d6b9f2-1291-4d2f-8805-aef94deac9f7 yum.repos.d]# pwd  /etc/y ...

  3. CodeForces - 755C PolandBall and Forest (并查集)

    题意:给定n个数,Ai的下标为1~n.对于每一个i,Ai与i在同一个树上,且是与i最远的点中id最小的点(这个条件变相的说明i与Ai连通).求森林中树的个数. 分析:若i与Ai连通,则在同一个树上,因 ...

  4. HihoCoder第十二周:刷油漆

    #1055 : 刷油漆 时间限制:10000ms 单点时限:1000ms 内存限制:256MB 描述 上回说到,小Ho有着一棵灰常好玩的树玩具!这棵树玩具是由N个小球和N-1根木棍拼凑而成,这N个小球 ...

  5. asp.net增加指定404页面

    对于在asp中添加404页面我并不熟悉,所以刚开始只能在网上找各种资料,网上资源太多,各种借鉴.   1.借鉴网上尝试的第一种方法:   首先,修改应用程序根目录的设置,打开 “web.config” ...

  6. 中文文本分类之CharCNN

    文本分类是自然语言处理中一个非常经典的任务,可用的模型非常多,相关的开源代码也非常多了.这篇博客用一个CNN模型,对新闻文本进行分类. 全部代码有4个模块:1.数据处理模块(命名为:cnews_loa ...

  7. nginx常用配置解析

    1.常用公共参数(一般放在http下面,虽然很多参数都支持server和location) keepalive_timeout  60;  #单位为s keepalive_request 2;  #设 ...

  8. Go语言 一维数组的使用

    程序源码 package main import ( "fmt" // 导入 fmt 包,打印字符串是需要用到 ) func main() { // 声明 main 主函数 var ...

  9. 自定义spark UDAF

    官网链接 样例代码: import java.util.ArrayList; import java.util.List; import org.apache.spark.sql.Dataset; i ...

  10. POJ 2104 求序列里第K大 主席树裸题

    给定一个n的序列,有m个询问 每次询问求l-r 里面第k大的数字是什么 只有询问,没有修改 可以用归并树和划分树(我都没学过..囧) 我是专门冲着弄主席树来的 对主席树的建树方式有点了解了,不过这题为 ...