zoukankan      html  css  js  c++  java
  • mysql误删root用户

    在操作mysql时误删除root用户,如何进行恢复

    在安装hive时候误删除root用户,存在的用户没有权限,解决方法如下。

    1、首先在/etc/my.cnf文件中 mysqlID下面添加

    skip-grant-tables

    用来跳过安全密码验证

    2、在服务上重启mysql服务

    [root@master2 bin]# systemctl restart mysqld.service

    3、使用mysql直接进入mysql

    [root@master2 bin]# mysql

    4、使用mysql数据库

    mysql> use mysql;

    5、重新添加用户

    insert into user(user,host,password,ssl_type,ssl_cipher,x509_issuer,x509_subject) values('root','localhost',PASSWORD('MyPass@123'),'','','','');

    6、对新添加用户进行授权

    mysql> grant all privileges on *.* to root@"loaclhost" identified by 'MyPass@123';

    此时报错,因为处于skip-grant-tables

    ERROR 1290 (HY000): The MySQL server is running with the --skip-grant-tables option so it cannot execute this statement

    解决:

    先执行

    flush privileges;

    再执行

    mysql> grant all privileges on *.* to root@"loaclhost" identified by 'MyPass@123';
    flush privileges;

    此时查看新添加用户的权限

    mysql>  select * from mysql.user where user='root'G;

    此时退出mysql,在服务上的/etc/my.cnf文件上删除掉skip-grant-tables

    重启mysql服务

    [root@master2 bin]# vim /etc/my.cnf
    [root@master2 bin]# systemctl restart mysqld.service

    重新初始化

    schematool -initSchema -dbType mysql

  • 相关阅读:
    装饰器和表达生成式
    函数
    字符编码
    函数基础
    列表,字典与集合
    Linux Semaphore
    tp5安装easyWeChat
    wx.request
    小程序设计规范
    小程序的概念和特点
  • 原文地址:https://www.cnblogs.com/nongzihong/p/15357716.html
Copyright © 2011-2022 走看看