忘记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. 第一个maven项目

    1.新建maven project 注意:勾上create a new simple project 2.填写相关信息, Grounp id为大项目名字,Artifact id为小项目的名字.注意:P ...

  2. Ubuntu安装配置MySQL数据库,Apache,PHP

    MySQL安装 第一步:首先检查是否安装: sudo netstat -tap| grep mysql 如果没有任何反应则没有安装 第二步:执行命令安装mysql: sudo apt-get inst ...

  3. python----题库(一)

    1.执行 Python 脚本的两种方式 答:1.>>python ../pyhton.py 2. >>python.py #必须在首行有 #!/usr/bin/env pyth ...

  4. ZH奶酪:JavaScript调用AngularJS的函数/$scope/变量

    使用背景: 需要在其他JavaScript文件中调用AngularJS内部方法或改变$scope变量,同时还要保持双向数据绑定: 首先获取AngularJS application: 方法一:通过co ...

  5. POJ_2533_Longest Ordered Subsequence

    Longest Ordered Subsequence Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 55490   Acc ...

  6. bokeyuan_python文章爬去入mongodb读取--LOWBIPROGRAMMER

    # -*- coding: utf-8 -*- import requests,os from lxml import etree from pymongo import * class Boke(o ...

  7. flask简单的路由分发

    flask简单的路由分发 from flask import Flask, request app = Flask(__name__) @app.route('/hello') def index() ...

  8. mysql transaction 事务

    1.事务简介 一个"最小的"不可再分的"工作单元". 一个事务通常对应了一个完整的业务.如:银行的转账功能,a转账给b,a扣钱,b加钱. 一个事务包含一条或多条 ...

  9. URAL 1517 Freedom of Choice (后缀数组 输出两个串最长公共子串)

    版权声明:本文为博主原创文章,未经博主同意不得转载. https://blog.csdn.net/whyorwhnt/article/details/34075603 题意:给出两个串的长度(一样长) ...

  10. 010-spring cloud gateway-过滤器-自定义局部、全局过滤器、区别

    一.自定义局部过滤器 自定义过滤器需要实现GatewayFilter和Ordered.其中GatewayFilter中的这个方法就是用来实现你的自定义的逻辑的 Mono<Void> fil ...