zoukankan      html  css  js  c++  java
  • Linux环境下java开发环境搭建四 mysql密码忘记找回

    第一步:在/etc/my.cnf配置文件中加入skip-grant-tables

    [mysqld]
    basedir=/usr/local/mysql
    datadir=/usr/local/mysql/data
    user=mysql
    # Disabling symbolic-links is recommended to prevent assorted security risks
    symbolic-links=0
    default-storage-engine=InnoDB
    innodb-file-per-table=1
    character_set_server=utf8mb4
    
    skip-grant-tables
    [mysqld_safe]
    
    [client]
    default-character-set=utf8mb4

    第二步:重启mysql

    [root@slave1 mysql]# service mysqld restart
    Shutting down MySQL.. SUCCESS! 
    Starting MySQL. SUCCESS! 

    第三步:不使用密码直接登录mysql,然后修改mysql.user表中的authentication_string字段的值

    在mysql 5.7之前,mysql数据库用户的密码的字段是password,5.7之后变成了authentication_string

    mysql> update mysql.user set authentication_string=password('123456') where user='root' and host='localhost';
    Query OK, 1 row affected, 1 warning (0.02 sec)
    Rows matched: 1  Changed: 1  Warnings: 1
    
    mysql> flush privileges;
    Query OK, 0 rows affected (0.00 sec)
    
    mysql> q

    注意一定要执行flush privileges;不然不会生效,重置完密码之后,要把my.cnf配置文件中的skip-grant-tables注释到

  • 相关阅读:
    LCS 最长公共子序列
    零和数组
    Learn2Rank
    ac自动机
    208. Implement Trie (Prefix Tree)
    php截取中文字符串 GB2312 utf-8
    纵向文字滚动代码,带上下图片控制的。鼠标放到上下图片上时滚动
    js图片切换 带左右控制的
    实时显示输入的内容
    Lightbox JS v2.0图片切换效果
  • 原文地址:https://www.cnblogs.com/cplinux/p/10803162.html
Copyright © 2011-2022 走看看