1、关闭数据库

脚本:[root@mysql etc]# service mysql stop

2、使用脚本: mysqld_safe --skip-grant-tables 启动数据库

使用/usr/bin/mysqld_safe --skip-grant-tables&启动数据库

3、使用空密码进入数据库(mysql命令后直接回车)

[root@mysql ~]# mysql

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

Your MySQL connection id is 3

Server version: 5.6.20-enterprise-commercial-advanced MySQL Enterprise Server - Advanced Edition (Commercial)

Copyright (c) 2000, 2014, 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、使用UPDATE语句修改ROOT密码

mysql> UPDATE mysql.user SET

-> PASSWORD=PASSWORD('root')

-> where

-> User='root' AND Host='localhost';

5、关闭数据库并重新以正常方式启动数据库

[root@mysql ~]# service mysql restart;

Shutting down MySQL.. SUCCESS!

Starting MySQL.. SUCCESS!

[root@mysql ~]# mysql

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

[root@mysql ~]# mysql -p

Enter password:

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

Your MySQL connection id is 2

Server version: 5.6.20-enterprise-commercial-advanced MySQL Enterprise Server - Advanced Edition (Commercial)

Copyright (c) 2000, 2014, 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修改密码和忘记ROOT密码的更多相关文章

  1. mysql 免安装与 忘记root密码 密码过期

    免安装: 参考 :https://blog.csdn.net/werwqerwerwer/article/details/52919939 注:别忘了配置环境变量   忘记root密码解决办法: 1. ...

  2. ubuntu 忘记密码,忘记root密码的解决办法

    ubuntu的root默认是禁止使用的,在安装的时候也没有要求设置root的密码.要使用,给root设置密码就行了,sudo passwd root .如果只是普通用户密码忘了,用root就可以修改. ...

  3. mysql 5.7.16 忘记root 密码 如何修改root密码

    今天在电脑上安装  mysql5.7.16 (压缩包)时,在初始化data文件夹之后,没有记住密码,DOS框没有显示,没办法,为了学习一下怎么修改密码,在网上找了好多方法去解决,最终还是解决了,下面来 ...

  4. mysql 5.7.26 忘记root密码

    1.关闭mysql [root@mysql ~]# /etc/init.d/mysqld stopShutting down MySQL.. SUCCESS! 2.修改参数文件/etc/my.cnf ...

  5. ubuntu忘记密码,忘记root密码的解决方法

    转载于http://forum.ubuntu.org.cn/viewtopic.php?t=272164 ubuntu的root默认是禁止使用的,在安装的时候也没要求你设置root的密码,和红帽系统系 ...

  6. MySQL 5.7忘记root密码如何修改?

    一直以来,MySQL的应用和学习环境都是MySQL 5.6和之前的版本,也没有去关注新版本MySQL 5.7的变化和新特性.今天帮人处理忘记root密码的时时候,发现以前的方法不奏效了.具体情况如下所 ...

  7. skip-grant-tables 修改linux的mysql忘记root密码

    skip-grant-tables 修改linux的mysql忘记root密码 今天修改mysql中的admin用户权限,在执行update user set host =' %' where use ...

  8. yum 安装 Mysql error ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES) 开启远程连接 修改登入密码 忘记root密码 配置防火墙规则 随手mark

    yum 安装 MYsql:        yum install mysql mysql-server mysql-devel -y 1.1 登入报错: ERROR 1045 (28000): Acc ...

  9. MYSQL忘记root密码后如何修改

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

随机推荐

  1. 【Unity笔记】UGUI的Text文本框的大小随着文本字数变化

    需求:UGUI的Text文本框的内容会随着文本字数多少/换行而自动改变大小. 给Text加一个Content Size Filter组件(脚本),设置Horizontal Fit和Vertical F ...

  2. 临时文件夹迁移 temp位置移动

    方法/步骤 首先,在其他驱动器新建一个文件夹,给临时文件夹安个新家 桌面,右键"我的电脑",选择"属性" 点击"高级系统设置" 点击&quo ...

  3. Excel数据批量导入到SqlServer的方法

    1,以Excel为数据源建立连接导入. 关键点在于Excel的数据要有表头,表头要和数据库表的列名一样.连接字符串中HDR=YES不能省略,也就是第一行是表头的意思.IMEX=1;是把数据都当作字符串 ...

  4. 非常有用的15个Linux 服务器监控命令

    如果你想知道你的服务器正在做干什么,你就需要了解一些基本的命令,一旦你精通了这些命令,那你就是一个 专业的 Linux 系统管理员. 有些 Linux 发行版会提供 GUI 程序来进行系统的监控,例如 ...

  5. map-reduce 优化

    map阶段优化 参数:io.sort.mb(default 100) 当map task开始运算,并产生中间数据时,其产生的中间结果并非直接就简单的写入磁盘. 而是会利用到了内存buffer来进行已经 ...

  6. Java设计模式(17)解释器模式(Interpreter模式)

    Interpreter定义:定义语言的文法,并且建立一个解释器来解释该语言中的句子. Interpreter似乎使用面不是很广,它描述了一个语言解释器是如何构成的,在实际应用中,我们可能很少去构造一个 ...

  7. javascript验证键盘keycode

    document.onkeyup = function(event){ var event = event || window.event; alert(event.keyCode); }

  8. C++ vector清空元素的三种方法

    #include <iostream> #include <vector> using namespace std; //STL vector的几种清空容器(删除)办法 voi ...

  9. 【转】常用 Microsoft .NET Framework 各版本下載網址列表

    研究] 常用 Microsoft .NET Framework 各版本下載網址列表 2014-05-23 僅列常用的 (IA64, Beta, hotfix, ... 不列) Microsoft .N ...

  10. webrtc 在MAC下和iOS下的编译

    一:安装brew和git 1. mkdir /usr/local 2. curl -LsSf http://github.com/mxcl/homebrew/tarball/master | sudo ...