才装完的mysql,转眼密码就忘记了,找了一圈的修改密码方法,做下记录!

  1. 编辑mysql配置文件。
[root@localhost ~]# vi /etc/my.cnf
  1. [mysqld]配置节下新增 skip-grant-tables
# For advice on how to change settings please see
# http://dev.mysql.com/doc/refman/5.7/en/server-configuration-defaults.html [mysqld]
#
# Remove leading # and set to the amount of RAM for the most important data
# cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%.
# innodb_buffer_pool_size = 128M
#
# Remove leading # to turn on a very important data integrity option: logging
# changes to the binary log between backups.
# log_bin
#
# Remove leading # to set options mainly useful for reporting servers.
# The server defaults are faster for transactions and fast SELECTs.
# Adjust sizes as needed, experiment to find the optimal values.
# join_buffer_size = 128M
# sort_buffer_size = 2M
# read_rnd_buffer_size = 2M
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock skip-grant-tables # Disabling symbolic-links is recommended to prevent assorted security risks
"/etc/my.cnf" 29L, 979C written
  1. 保存配置文件后,重启mysql服务。
[root@localhost ~]# systemctl restart mysqld.service
  1. 使用mysql命令登录mysql数据库。
[root@localhost ~]# mysql
  1. 使用下面语句修改root密码,注意和之前版本的mysql语句不太一样。
mysql>update mysql.user set authentication_string=password('新密码') where user='root' ;
mysql>flush privileges ;
mysql>quit
  1. 编辑mysql配置文件,将之前添加的 skip-grant-tables去掉。
  2. 重启mysql服务。
[root@localhost ~]# systemctl restart mysqld.service

centos7下忘记mysql5.7密码的更多相关文章

  1. CentOS7 下使用root免密码输入自动登入gnome桌面

    如果系统默认启动图形界面: vi /etc/gdm/custom.conf #找到[daemon],修改为下面的 [daemon] AutomaticLoginEnable=true Automati ...

  2. CentOS7下安装MySQL5.7安装与配置

    介绍在CentOS7上yum安装数据库服务器MySQL Community Server 5.7的方法. 准备 CentOS7默认安装了和MySQL有兼容性的MariaDB数据库,在我们安装MySQL ...

  3. 运维笔记--linux下忘记mysql root密码

    补充链接:Windows下忘记密码处理: https://www.cnblogs.com/hellojesson/p/5972950.html 场景描述: Linux环境下忘记 root 密码, 1. ...

  4. centos7 忘记mysql5.7密码

    编辑my.cnf文件,允许空密码登录 vi /etc/my.cnf 在[mysqld] 插入: skip-grant-tables [mysqld] datadir=/var/lib/mysql so ...

  5. centos7下安装mysql5.7.17

    约定:本文基于Centos7,Mysql5.7.17,经过博主多次测试成功 1.下载mysql.tar.gz 官网下载MySQL安装包,Linux-Generic 64位(根据系统选择64or32) ...

  6. Centos7下安装mysql5.7.16

    mysql的安装(root用户下) 从官网下载软件 linux下必须安装系统对应的版本,多少位 必须安装的是:server,client 但是我可不管要安装那个插件,我们直接使用bundle版本(就是 ...

  7. CentOS7下安装MySQL5.7安装与配置(转)

    原文地址:http://www.centoscn.com/mysql/2016/0626/7537.html 安装环境:CentOS7 64位 MINI版,安装MySQL5.7 1.配置YUM源 在M ...

  8. CentOS7下安装MySQL5.7安装与配置(YUM)

    http://blog.csdn.net/xyang81/article/details/51759200 安装环境:CentOS7 64位 MINI版,安装MySQL5.7 1.配置YUM源 在My ...

  9. centos7下配置mysql5.7.24主从复制

    前置条件 准备两台服务器(可以是虚拟机),系统为centos7 此处演示的两台服务器:192.168.8.134.192.168.8.135 第一步:安装mysql5.7.24 先在两台服务器上安装m ...

随机推荐

  1. Python 日期和时间 —— datetime

    Python 日期和时间 —— datetime Python提供了多个内置模块用于操作日期时间,如calendar,time,datetime.calendar用于处理日历相关 :time提供的接口 ...

  2. SpringMVC之HandlerMethodArgumentResolver和<mvc:argument-resolvers>

    SpringMVC提供了一个HandlerMethodArgumentResolver接口可以让我们处理方法的参数,和注解结合提来,能有很强大的功能,例如SpringMVC提供的@ModelAttri ...

  3. iOS:视图切换的第一种方式:模态窗口

    一.UIModalController:模态窗口(一个控制器模态出另一个控制器的模态窗口) 当我们在view controller A中模态显示view controller B的时候,A就充当pre ...

  4. Android模拟器怎么配置网络连通

    PC机可以上网,PC机上面的android模拟器不能上网.其实只要使模拟器跟自己的PC在同一个网段内就行了: 首先,如果没有配置sdk的环境变量的,那么在CMD命令下进入sdk安装路径的platfor ...

  5. Shell学习:grep, sed, awk命令的练习题

    http://www.cnblogs.com/chengmo/archive/2013/01/17/2865479.html 文件:datafileSteve Blenheim:238-923-736 ...

  6. c++学习之多态(虚函数和纯虚函数)

    c++是面向对象语言,面向对象有个重要特点,就是继承和多态.继承之前学过了,就是一种重用类的设计方式.原有的类叫父类,或者基类,继承父类的类叫子类.在设计模式中,我们总是要避免继承,推荐用组合.因为继 ...

  7. SQL Server 2012不支持Microsoft Visual Studio Test Controller 2010

    折腾了一个上午, 发现Test Controller怎么都连不上SQL. 能尝试的都尝试了, 觉得应该看看是不是有不支持的问题.   找到了这篇. TFS 2010 will not support ...

  8. wifi连接android设备进行调试

    手机下载终端模拟器: 并输入例如以下$ su # setprop service.abd.tcp.port 5555 # stop adbd # start adbd 在cmd中输入adb conne ...

  9. ejs和swig对比问题之二

    上一次用浏览器里面简单的进行了测试,得到的数据是swig是ejs的速度的一倍左右,这次在控制台进行测试,能够得到比较精确的数据,并加入了dot一块儿进行测试. 测试数据是一百万条记录 创建测试数据cr ...

  10. leetCode 45.Jump Game II (跳跃游戏) 解题思路和方法

    Jump Game II Given an array of non-negative integers, you are initially positioned at the first inde ...