• mysql修改root密码的多种方法


    mysql修改root密码的多种方法

     

    方法1: 用SET PASSWORD命令

      mysql -u root

      mysql> SET PASSWORD FOR 'root'@'localhost' = PASSWORD('newpass');

    方法2:用mysqladmin

      mysqladmin -u root password "newpass"

      如果root已经设置过密码,采用如下方法

      mysqladmin -u root password oldpass "newpass"

    方法3: 用UPDATE直接编辑user表

      mysql -u root

      mysql> use mysql;

      mysql> UPDATE user SET Password = PASSWORD('newpass') WHERE user = 'root';

      mysql> FLUSH PRIVILEGES;

    在丢失root密码的时候,可以这样

    复制代码
    [root@mysql ~]# /etc/init.d/mysqld stop
    Shutting down MySQL. SUCCESS!
    
    [root@mysql ~]# mysqld_safe --skip-grant-tables&
    [1] 27426
    [root@mysql ~]# 170220 18:48:38 mysqld_safe Logging to '/application/mysql/data/mysql.err'.
    170220 18:48:38 mysqld_safe Starting mysqld daemon with databases from /application/mysql/data
    
    [root@mysql ~]# mysql -uroot -p
    Enter password: 
    Welcome to the MySQL monitor. Commands end with ; or g.
    Your MySQL connection id is 1
    Server version: 5.5.49 MySQL Community Server (GPL)
    
    Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.
    
    Oracle is a registered trademark of Oracle Corporation and/or its
    affiliates. Other names may be trademarks of their respective
    owners.
    
    Type 'help;' or 'h' for help. Type 'c' to clear the current input statement.
    
    mysql> UPDATE mysql.user SET password=PASSWORD("oldboy123") WHERE user='root';
    Query OK, 4 rows affected (0.00 sec)
    Rows matched: 4 Changed: 4 Warnings: 0
    
    mysql> flush privileges;
    Query OK, 0 rows affected (0.01 sec)
    
    mysql> exit
    Bye
    复制代码

     方法四:

    自己查找路径:

    /etc/mysql/conf.d/

    /etc/mysql/mysql.conf.d/

  • 相关阅读:
    7zip 自解压安装程序
    修改当前启动菜单项的HyperVisorLaunchType
    VMware 虚拟镜像转 Hyper-V(Win10/2016)
    旋转基础知识
    变换及移动基础知识
    文字及排版章末小结
    文字排版相关
    文字变形及封套扭曲
    LinQ学习笔记.
    PHP笔记-PHP中Web Service.
  • 原文地址:https://www.cnblogs.com/dengbingbing/p/10429066.html
Copyright © 2020-2023  润新知