zoukankan      html  css  js  c++  java
  • centos7下忘记mysql5.7密码

    才装完的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
    
  • 相关阅读:
    Linq系列:基础与本质(Part III)
    CLR系列:浅析委托
    8万亿 全球第二还是最二?
    CLR系列:窥视HashTable
    c#3.0系列:Anonymous Type In CLR(3.5)
    VC6 编译选项问题
    C++资源库不完全版本
    如何用C实现C++的特性
    几种用于WSN的仿真工具
    嵌入式编程的好资源
  • 原文地址:https://www.cnblogs.com/yanziwen/p/9215264.html
Copyright © 2011-2022 走看看