• Linux下重新设置 MySQL 的密码


    1.重置密码的第一步就是跳过MySQL的密码认证过程,方法如下:

    #vim /etc/my.cnf(注:windows下修改的是my.ini)

    很多老铁,在开始时设置了 MySQL 的密码,后来一段时间没有用 MySQL之后,密码忘了~ QAQ,请别急,现在有以下方法解决密码忘了的情况。

    1.首先我们需要跳过 MySQL 的密码认证:

    (1)进入 /etc/my.cnf 文件

    [root@localhost ~]# vim /etc/my.cnf

    (2)在 [mysqld] 的下面添加 " skip-grant-tables " 用来跳过 MySQL 登录时候的密码验证:

    [mysqld]
    skip-grant-tables

    2.重启下 MySQL :

    [root@localhost lib]# systemctl restart mysqld.service

    3.进入 MySQL 中使用命令对密码进行修改:

    //使用名字叫 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
    //这里我把 账号 root 密码设置为 root
    mysql> update mysql.user set authentication_string=password('root') where user='root' ;
    Query OK, 1 row affected, 1 warning (0.00 sec)
    Rows matched: 1  Changed: 1  Warnings: 1
    
    // 刷新
    mysql> flush privileges;
    Query OK, 0 rows affected (0.00 sec)
    
    mysql> quit
    Bye

    4.验证是否对密码重新设置成功:

    [root@localhost /]# mysql -uroot -proot
    //注意:这里一般直接输入密码登录,可能会不安全
    
    mysql: [Warning] Using a password on the command line interface can be insecure.
    ......
  • 相关阅读:
    bzoj3809
    bzoj2038
    bzoj1113
    oralce 知识
    oracle 12c安装详细教程
    oracle 知识点
    oracle 面试题
    PLSQL Developer工具的使用
    使用net Manager工具配置远程连接oracle
    vnc安装
  • 原文地址:https://www.cnblogs.com/xiaowei123/p/13113607.html
Copyright © 2020-2023  润新知