zoukankan      html  css  js  c++  java
  • 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/

  • 相关阅读:
    在ModelSim中添加Xilinx仿真库
    关于DDR3非常棒的文章
    Modelsim编译Xilinx器件库的另一种方法
    FPGA按键去抖verilog代码
    DDOS与DDOS追踪的介绍
    自动实时监控Windows2003服务器终端登录
    Java 如何实现线程间通信
    C# 获取FormData数据
    利用 FormData 对象发送 Key/Value 对的异步请求
    jdk初始安装配置
  • 原文地址:https://www.cnblogs.com/dengbingbing/p/10429066.html
Copyright © 2011-2022 走看看