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. systemd&systemctl

    systemd is a system and service manager for Linux operating systems. When run as first process on bo ...

  2. fresco中设置占位/加载失败的图片 无效

    在xml中设置  placeholderImage  属性无效.代码如下: <com.facebook.drawee.view.SimpleDraweeView android:id=" ...

  3. ajax传递参数给springmvc总结[转]

    通过ajax传递参数给springmvc,经常会因为 参数类型太复杂,或者根本不知道springmvc都支持哪些类型转换,导致后台接收出现各种问题.如果书写格式没有问题仍然接受参数报错,大部分是因为s ...

  4. 总结一些笔记上的C和C++知识点

    1.如果没有提供自己的copy构造函数,C++会提供一个默认的copy构造函数,是成员到成员的copy. 2.C中static的作用: 1.隐藏:如果未加static,编译多个文件的时候,所有的全局变 ...

  5. java从字符串中提取数字

    string类函数的补充说明: trim()方法返回调用字符串对象的一个副本,但是所有起始和结尾的空格都被删除了,例子如下:String s=" Hello World ".tri ...

  6. Axiom3D:Ogre中Mesh文件格式分析(一)

    在Axiom3D,或者说是Ogre的mesh的文件格式我们可能通过代码反推出相关格式,相关过程本来我是直接写的,后面发现相关流程写完后,我自己都看晕了,然后我就把一些过程用Execl整理出来,发现过程 ...

  7. pymysql和MySQLdb

    MySQLdb创建mysql数据库表 其实mysqldb创建表是有限制的,要求是5.1-5.5版本 pymsql是Python中操作MySQL的模块,其使用方法和MySQLdb几乎相同. 1.下载 首 ...

  8. android 监听声音变化

    新的项目需要监听android声音的变化,再做出对应的操作,从网上找了个demo验证.记录于此. 参考链接 https://my.oschina.net/yuanxulong/blog/372268 ...

  9. Android hide Navigation bar

    最近一个app需要隐藏Navigation bar导航栏. 参考文档 http://blog.csdn.net/zwlove5280/article/details/52823128 http://j ...

  10. 一些基本的操作,编译,构建,单元测试,安装,网站生成和基于Maven部署项目。

    一些基本的操作,编译,构建,单元测试,安装,网站生成和基于Maven部署项目. 使用Maven构建项目“mvn package” 来构建项目 使用Maven清理项目“mvn clean” 来清理项目 ...