zoukankan      html  css  js  c++  java
  • Mark一下 mysql 误删除root用户的解决方法

    今天学习mysql用户管理,不小心将mysql.user表中的root用户给删掉了,然后就无法登录mysql了,网上找到了linux下的解决方法,我做了简单的修改,改成了我的windows版,恢复方法如下:

    1、关闭mysql服务
    net stop mysql 或者 wamp工具关闭
    2、启动无需验证用户的特权使用模式
    切换到mysql的bin目录,执行mysqld  --console --skip-grant-tables
    3、使用root用户登录(没有密码),重新授权
    grant all privileges on *.* to root@'localhost' identified by '密码' with grant option;
    flush privileges;
    exit
    注:如果grant 授权报错:ERROR 1290 (HY000): The MySQL server is running with the --skip-grant-tables option so it cannot execute this statement,请先执行一次flush privileges;,然后再grant授权即可。
    4、退出特权模式(Ctrl+C)
    5、正常启动mysql,即可恢复使用
     
    网上看到的linux的恢复办法
    1、关闭mysql
    /etc/init.d/mysql stop
    2、启动无需验证用户的特权使用模式
    /usr/local/mysql/bin/mysqld_safe --user=mysql --skip-grant-tables --skip-networking &
    3、使用root用户登录(没有密码),重新授权
    mysql -uroot
    grant all privileges on *.* to root@'localhost' identified by '密码' with grant option;
    flush privileges;
    exit
    4、重启mysql服务,即可恢复使用
    /etc/init.d/mysql restart
  • 相关阅读:
    lsblk命令详解
    lspci命令详解
    numastat命令详解
    lsscsi命令详解
    lscpu命令详解
    linux内核模块相关命令:lsmod,depmod,modprobe,modinfo,insmod,rmmod 使用说明
    elk收集tomcat的日志
    npm安装
    centos7.5 解决缺少libstdc++.so.6库的原因及解决办法
    linux下正确卸载rpm包
  • 原文地址:https://www.cnblogs.com/youngerger/p/8529066.html
Copyright © 2011-2022 走看看