• mysql 5.7忘记密码


    1、

    https://blog.csdn.net/zzzcl112/article/details/80484495?utm_medium=distribute.pc_relevant.none-task-blog-BlogCommendFromMachineLearnPai2-2.nonecase&depth_1-utm_source=distribute.pc_relevant.none-task-blog-BlogCommendFromMachineLearnPai2-2.nonecase

    以上的修改密码改为了命令:

    UPDATE mysql.user SET authentication_string = PASSWORD('MyNewPassword') WHERE User = 'root' AND Host = 'localhost';

    否则会报错;

    ————————————————

    方法二:

    该方法先修改mysql配置文件使其可以无密码登录,让后修改密码,之后便复原配置文件

    修改/etc/my.cnf

    vim /etc/my.cnf 

    配置文件添加skip-grant-tables

    [root@VM_0_8_centos ~]# vim /etc/my.cnf
    
    # For advice on how to change settings please see
    # http://dev.mysql.com/doc/refman/5.6/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
    symbolic-links=0
    

    保存后重启mysql

    systemctl restart mysql

    即可免密登录,命令行输入mysql直接登录

    选择mysql数据库,输入下列命令重置密码,'new-password'即为所设置密码

    USE mysql;
    UPDATE mysql.user SET authentication_string = PASSWORD('MyNewPassword') WHERE User = 'root' AND Host = 'localhost';
    修改完成后输入exit退出,重新回到/etc/my.cnf该文件删除之前添加语句即可完成
  • 相关阅读:
    css !import
    算法
    java web 运动前端
    oauth 2
    js 优化
    js 代码优化 (写的可以)
    2015/08/17 《有两条均线,你应该注意》
    佳能相机操作 EDSDK 教程 C# 版本
    2015/8/14——了2000股,是否正确呢——明天待验证?
    系统架构师考试——程序计数器 PC, 指令寄存器IR、状态寄存器SR、通用寄存器GR
  • 原文地址:https://www.cnblogs.com/yaok430/p/13677418.html
Copyright © 2020-2023  润新知