zoukankan      html  css  js  c++  java
  • mysql 重设管理员密码 或忘记管理员密码 (必杀)

    Windows:  
    1. 用系统管理员登陆系统。  
    2. 停止MySQL的服务。  
    3. 进入命令窗口(cmd),然后进入MySQL的安装目录,比如我的安装目录是c:\mysql,进入C:\mysql\bin  
    4. 跳过权限检查启动MySQL,  
    c:\mysql\bin>mysqld-nt --skip-grant-tables 
    5. 重新打开一个cmd窗口,进入c:\mysql\bin目录,设置root的新密码  
    c:\mysql\bin>mysqladmin -u root flush-privileges password "newpassword" 
    c:\mysql\bin>mysqladmin -u root -p shutdown 
    将newpassword替换为你要用的root的密码,第二个命令会提示你输入新密码,重复第一个命令输入的密码。  
    6. 停止MySQL Server,用正常模式启动Mysql  
    7.你可以用新的密码链接到Mysql了。  

    Unix&Linux:  
    1.用root或者运行mysqld的用户登录系统;  
    2.利用kill命令结束掉mysqld的进程;  
    3.使用--skip-grant-tables参数启动MySQL Server  

    查找本机的mysql安装位置

    #find / -name mysqld_safe

     
    #mysqld_safe --skip-grant-tables 
    4.为root@localhost设置新密码  

    mysql> use mysql 
    mysql> UPDATE user SET password=password('newpassword') WHERE user='root'; 

    注:如是4.1以上版本则使用old_password()函数进行密码更改。
    mysql> FLUSH PRIVILEGES; 

    mysql>exit
    service mysqld restart

     

     

  • 相关阅读:
    SSM应用(五)--参数绑定
    SSM应用(四)--SpringMVC入门
    Oracle常用函数
    SSM应用(三)--Spring整合MyBatis
    SSM应用(二)--注解的使用
    SSM应用(一)--Spring入门
    MyBatis学习(十四)--逆向工程使用
    MyBatis学习(十三)--缓存
    MyBatis学习(十二)--懒加载
    MySQL常用函数
  • 原文地址:https://www.cnblogs.com/Qbit/p/1957564.html
Copyright © 2011-2022 走看看