关闭正在运行的 MySQL :

1
[root@www.woai.it ~]# service mysql stop

运行

1
[root@www.woai.it ~]# mysqld_safe --skip-grant-tables &

为了安全可以这样禁止远程连接:

1
[root@www.woai.it ~]# mysqld_safe --skip-grant-tables --skip-networking &

使用mysql连接server:

1
[root@www.woai.it ~]# mysql -p

更改密码:

1
mysql> update mysql.user set authentication_string=password('123qwe') where user='root' and Host = 'localhost';

*特别提醒注意的一点是,新版的mysql数据库下的user表中已经没有Password字段了

而是将加密后的用户密码存储于authentication_string字段

1
2
mysql> flush privileges;
mysql> quit;

修改完毕。重启

1
[root@localhost ~]# service mysql restart

然后mysql就可以连接了

但此时操作似乎功能不完全,还要alter user…

1
mysql> alter user 'root'@'localhost' identified by '123';

这样也可以:

1
mysql> set password for 'root'@'localhost'=password('123');

重点给大家介绍下mysql 5.7 root密码修改

MySQL管理者密码设置或修改:

依据官方说明5.6以后版本,第一次启动时会在root目录下生产一个随机密码,文件名.mysql_secret。

1
2
3
4
5
[root@bright ~]# cat /root/.mysql_secret
# Password set for user 'root@localhost' at 2015-03-27 23:12:10
:Jj+FTiqvyrF
[root@bright ~]# cd /usr/local/mysql/bin/
[root@bright bin]# ./mysqladmin -u root -h localhost password '123456' -p

Enter password: #此行输入.mysql_secret里第二行内容

1
2
mysqladmin: [Warning] Using a password on the command line interface can be insecure.
Warning: Since password will be sent to server in plain text, use ssl connection to ensure password safety.

官方的方式,笔者无论是否使用--skip-grant-tables启动mysql都测试失败,亲们可以测试:

1
2
shell>mysql -uroot -p'password' #password即.mysql_secret里的密码
mysql>SET PASSWORD = PASSWORD('newpasswd');

旧版本,安装后ROOT无密码,按如下操作:

方法一:

1
2
3
4
5
6
7
shell>service mysqld stop #停止mysql服务
shell>mysqld_safe --skip-grant-tables & #以不启用grant-tables模式启动mysql
shell>mysql -uroot -p #输入命令回车进入,出现输入密码提示直接回车。
mysql>use mysql;
mysql>update user set password=PASSWORD("123456")where user="root"; #更改密码为 newpassord
mysql>flush privileges; #更新权限
mysql>quit #退出

方法二:

1
2
3
4
shell>service mysqld stop #停止mysql服务
shell>mysqld_safe --skip-grant-tables & #以不启用grant-tables模式启动mysql
shell>mysql -uroot -p #输入命令回车进入,出现输入密码提示直接回车。
mysql > set password for root@localhost = password('mysqlroot');

方法三:

1
shell>/path/mysqladmin -u UserName -h Host password 'new_password' -p

MySQL 5.7忘记密码的更多相关文章

  1. Win10 - MySQL 5.7 忘记密码

    Win10 - MySQL 5.7 忘记密码 # 关闭 mysql 服务 net stop mysql # 在命令行输入以下命令, 输入后新建一个 CMD 窗口 mysqld -nt --skip-g ...

  2. MySQL 5.7 忘记密码

    MySQL 5.7 忘记Root密码 用管理员身份运行cmd.然后使用命令进行: 1.打开MySQL>bin文件夹 >cd C:\mysql\mysql5.7.14\bin 2.停止mys ...

  3. MySQL root用户忘记密码怎么办?修改密码方法:skip-grant-tables

    忘记密码怎么办? 1.以管理员身份打开cmd2.执行命令tasklist |findstr mysql ,查看正在运行的mysql进程 3.执行命令taskkill /F /PID 13644(此处进 ...

  4. MySQL之从忘记密码到重置密码

    在对MySQL的应用中,难免会有忘记登陆密码的情况:接下来,将简单介绍下MySQL忘记密码如何登陆和重置密码的操作过程. 首先来说下新版MySQL(5.7+)的重置密码过程: 由于忘记登陆密码,所以正 ...

  5. 【转帖】MYSQL 8.0 忘记密码的简单处理。--init-file

    Copy From https://www.cnblogs.com/wangjiming/p/10363357.html mysql 不熟悉 但是感觉语法的确与oracle越来越像了. 感谢原作者 我 ...

  6. Windows下,MySQL root用户忘记密码解决方案

    同时打开2个命令行窗口,并按如下操作: <1>.在第一个“命令行窗口”输入: cd  D:\Program Files\MySQL\MySQL Server 5.5\bin net sto ...

  7. linux下mysql 8.0忘记密码后重置密码

    1://免密码登陆 找到mysql配置文件:my.cnf, 在[mysqld]模块添加:skip-grant-tables   保存退出: 2://使配置生效 重启mysql服务:  service ...

  8. Linux MySQL 8.0 忘记密码

    不小忘了MySQL的密码,按照书上和网上的内容都没能修改成功,终于在借鉴了多篇文章成功之后找到原因,修改密码成功 修改 MySQL 密码 第一步:关闭 MySQL 进程 systemctl stop ...

  9. 一、mysql数据库,忘记密码怎么处理及处理过程中遇见的问题

    1.输入cmd命令打开控制台: 2.进入mysql.exe所在的路径: 3.执行mysqld --skip-grant-tables(注意:在输入此命令之前先在任务管理器中结束mysqld.exe进程 ...

随机推荐

  1. C语言——stdio.h

        int fgetc(FILE * stream); get character from stream 返回流中的一个字符,并以int的类型返回,如果碰到文件的结尾,或者一个错误发生,函数返回 ...

  2. C++中定义NULL的头文件

    NULL不是C语言基本类型,其定义在stddef.h文件中,作为最基本的语言依赖宏存在.但是随着C/C++的发展,很多文件只要涉及了系统或者标准操作都会将NULL作为标准宏声明或者包含.所以几乎包含任 ...

  3. Xcel 测试版使用手册

    基于无任何文笔可言,所以直接上使用方法吧. 1.引用dll,如何引用dll请谷歌. 2.使用 //实例化对象 LT.XMLExcel.XlsxOption xOption = new LT.XMLEx ...

  4. 53. Maximum Subarray(动态规划 求最大子数组)

      Find the contiguous subarray within an array (containing at least one number) which has the larges ...

  5. Linux 中的 Service

    参考: cnblogs.com/xiaofan21 - linux service和daemon cnblogs.com/xuange306 - linux service命令常见使用方法 cnblo ...

  6. [转][访谈]数据大师Olivier Grisel给志向高远的数据科学家的指引

    原文:http://www.csdn.net/article/2015-10-16/2825926?reload=1 Olivier Grisel(OG)本人在InriaParietal工作,主要研发 ...

  7. zw版【转发·台湾nvp系列Delphi例程】HALCON SetWindowExtent

    zw版[转发·台湾nvp系列Delphi例程]HALCON SetWindowExtent unit Unit1;interfaceuses Windows, Messages, SysUtils, ...

  8. gstreamer调试命令

    gplay播放命令 gplay 文件全路径 (eg:gplay 123.mp3) gstreamer播放命令 gst-launch playbin2 uri=file:///文件全路径 (eg  gs ...

  9. mongodb的存储引擎

    mongodb版本为3.4 mongodb存储引起的一些概述 存储引擎是MongoDB的核心组件,负责管理数据如何存储在硬盘和内存上.从MongoDB 3.2 版本开始,MongoDB 支持多数据存储 ...

  10. Easy install ryu

    参考:Ubuntu14.04安装Ryu控制器 环境:Ubuntu 14.04 64bit 使用pip安装ryu: // dependencies sudo apt-get install Python ...