zoukankan      html  css  js  c++  java
  • 解决“把Linux系统mysql唯一root用户的所有权限都给撤销了,导致登录了root账户无法进行任何操作”的问题

    自己作死把root得权限全给去掉了,然后导致无法添加用户等其他操作,然后就想办法补救

    1、修改mysql 配置文件,添加属性

    vi /etc/my.conf  # 你的配置文件可能不在这 
    
    skip-grant-tables  #添加这个属性,表示不校验权限密码等

    2、重启mysql

    service mysql restart
    
    # 或者
    systemctl restart mysql

    3、进入mysql 客户端

    3.1 进入mysql表

    use mysql

    3.2 授权

    update user set Host='%',select_priv='y',insert_priv='y',update_priv='y',Alter_priv='y',delete_priv='y',create_priv='y',drop_priv='y',reload_priv='y',shutdown_priv='y',Process_priv='y',file_priv='y',grant_priv='y',References_priv='y',index_priv='y',create_user_priv='y',show_db_priv='y',super_priv='y',create_tmp_table_priv='y',Lock_tables_priv='y',execute_priv='y',repl_slave_priv='y',repl_client_priv='y',create_view_priv='y',show_view_priv='y',create_routine_priv='y',alter_routine_priv='y',create_user_priv='y' where user='root';

    3.3 修改密码

    5.7版本以前:

    update mysql.user set password=password('root') where user='root';

    5.7及以上:

    update mysql.user set authentication_string=password('root') where user='root';

    其他更改密码方式:

    set password for root@localhost = password('123456');
    ALTER USER 'root'@'%' IDENTIFIED WITH mysql_native_password BY '123456';
    ALTER USER 'root'@'localhost' IDENTIFIED BY 'password' PASSWORD EXPIRE NEVER;

    4、刷新

    flush privileges;

    5、删掉第一步添加的属性 然后重启。

  • 相关阅读:
    hystrix项目实战
    hystrix实战总结;
    JAVA后端生成Token(令牌),用于校验客户端,防止重复提交
    如何防止表单的重复提交
    hystrix实战
    字符串为空的错误发生
    zuul的学习
    feign无法注入service
    springcloud实战案例苏宁和海信
    RPC与REST的区别
  • 原文地址:https://www.cnblogs.com/yang5726685/p/15741111.html
Copyright © 2011-2022 走看看