忘记root密码

如果不小心忘记了root密码,那么mysql就不能再登录了,这时就要重置root密码才行。通过下面的步骤,我们可以重新设置root密码。

1、退出mysql

[root@localhost src]# service mysqld stop

停止mysqld                                             [确定]

[root@localhost src]# 

2、进入sql安全模式,命令“/usr/bin/mysqld_safe --skip-grant-table &

[root@localhost src]#/usr/bin/mysqld_safe --skip-grant-table &

[1] 6332

[root@localhost src]# 180814 10:10:00 mysqld_safe Logging to '/var/log/mysqld.log'.

180814 10:10:00 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql

3、无密码方式登录,命令“mysql –u root”

[root@localhost src]# mysql -u root

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

Your MySQL connection id is 1

Server version: 5.1.71 Source distribution

Copyright (c) 2000, 2013, 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、使用mysql,命令“use mysql;”

mysql> use mysql;

Reading table information for completion of table and column names

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

Database changed

mysql> 

5、重设root密码,命令“update user set password=password (“密码”) where user=’root’”

mysql> update user set password=password('123456') where user='root';

Query OK, 3 rows affected (0.00 sec)

Rows matched: 3  Changed: 3  Warnings: 0

mysql> 

6、刷新

mysql> flush privileges;

Query OK, 0 rows affected (0.00 sec)

7、退出,重新登录

[root@localhost src]# mysql -u root -p

Enter password:        //这里输入新密码

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

Your MySQL connection id is 2

Sever version: 5.1.71 Source distribution

Copyright (c) 2000, 2013, 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> 

做了一个Linux学习的平台,目前出来一个雏形,各位可以参考使用
链接:https://pan.baidu.com/s/1GOLVU2CbpBNGtunztVpaCQ  密码:n7bk

Linux服务器---mysql忘记root密码的更多相关文章

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

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

  2. linux下mysql忘记root密码怎么办

    Linux下MySQL忘记root密码怎么办? Linux下MySQL忘记root密码怎么办? 1. 修改MySQL配置文件 默认MySQL的配置文件为/etc/my.cnf,在[mysqld]下面添 ...

  3. Linux下mysql忘记root密码

    一台机器上的MYSQL服务器很久没用了,忘了root密码无法连接.一时情急,网上搜寻办法,解决,记录在此备用. 修改MySQL的登录设置:  //不同的版本的Linux配置文件的位置也不一样,以Lin ...

  4. Linux 下mysql忘记root密码解决方法

    忘记root密码怎么办:1.关闭数据库2.使用-->mysqld_safe --skip-grant-tables &--<启动数据库3.使用空密码进入数据库(mysql命令后直接 ...

  5. linux下mysql忘记root密码的解决方案

    1.首先确认服务器出于安全的状态,也就是没有人能够任意地连接MySQL数据库. 因为在重新设置MySQL的root密码的期间,MySQL数据库完全出于没有密码保护的 状态下,其他的用户也可以任意地登录 ...

  6. 图文详解linux/windows mysql忘记root密码解决方案

    经常有用户过来咨询说自己的mysql服务器忘记密码了怎么办,为了更好的解决大家的困扰,本文特归档整理了windows和linux系统下,mysql忘记密码的解决方案.本文内容是我亲测实用,当然过程中踩 ...

  7. 【备忘录】CentOS服务器mysql忘记root密码恢复

    mysql的root忘记,现无法操作数据库 停止mysql服务service  mysql stop 然后使用如下的参数启动mysql, --skip-grant-tables会跳过mysql的授权 ...

  8. linux下mysql忘记root密码解决方法

    如果使用 MySQL 数据库忘记了root账号密码,可以通过调节配置文件,跳过密码的方式登数据库, 在数据库里面修改账号密码,一般默认的账号是 root 1.编辑 MySQL 配置文件 my.cnf ...

  9. mysql忘记root密码解决办法

    最近项目中的数据库我放在了服务器上,但是今天突然不能用了,进入服务器查看,果然是数据库不能进去了,所以今天来分享一个mysql忘记root密码的解决方案: 1.让mysql不载入权限表,命令:mysq ...

随机推荐

  1. Thinkphp 验证码点击刷新解决办法

    HTML代码如下: <span> <input type="text" name="code" placeholder="验证码&q ...

  2. gzip: stdin:unexpected end of file

    原因是文件下载的不完整,重新下载就好了,

  3. T49

    明天参加媳妇朋友的婚礼.今天晚上的火车,下班后匆忙的打了个的,正好到的哥交接班的时间拦了几辆车都不拉火车站!无奈-五分钟后打上车接上媳妇去火车站!正值五中学生放假路上各种堵!安阳这四线城市什么时候变的 ...

  4. Oracle备份恢复之rman备份oracle数据库

    备份需求和rman备份 oracle数据库的备份相关问答: 1)备份时数据库处于何种状态? 备份时数据库处于OPEN状态,这样数据库可以正常工作. 2)备份的数据备份在什么地方? 备份在本地磁盘. 3 ...

  5. 坐标转换convertRect

    // 目标view的直接父viwe                    目标view                                   要转换到的view [self.backgr ...

  6. nginx之配置proxy_set_header

    win10客户端请求web服务,win10的ip:192.168.223.1 nginx作为反向代理服务器:192.168.223.136 nginx作为后端web服务器:192.168.223.13 ...

  7. LoadRunner-关联(自动关联和手动关联)

    使用LR录制脚本,新建课程:每次新建课程都会产生一个新的courseid和partid,直接使用录制的脚本执行是不行的.所以用到了关联. 注:关联分手动和自动关联,自动关联搜索出一些不必要关联的数据, ...

  8. Elegant Construction---hdu5813(构造图)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5813 题意是:有n个点,每个点都能到达num个点,让我们构造任意一个有向图满足条件,即:使得 i 能到 ...

  9. mysql 权限管理 针对表的字段 级别 授权 columns_priv表

    针对Mike账号 db1库下面的t1表的 id,name字段授予select权限,age字段授予update权限 授权格式 select(要授权的字段,要授权的字段) 用户括号 括起来  .updat ...

  10. android 操作SD卡上的文件

    (1)说明:操作SD卡上的文件须要增加下面权限  在SD卡上创建和删除文件权限  <uses-permission android:name="android.permission.M ...