• 在linux中操作mysql误删root用户的应对方法


    1.停止数据库
    [root@db01 ~]# /etc/init.d/mysqld stop

    2.跳过授权表启动mysql
    [root@db01 ~]# mysqld_safe --skip-grant-tables --skip-networking &

    3.尝试创建用户
    mysql> create user root@'localhost' identified by '123';
    ERROR 1290 (HY000): The MySQL server is running with the --skip-grant-tables option so it cannot execute this statement
    mysql> grant all on *.* to root@'localhost' identified by '123';
    ERROR 1290 (HY000): The MySQL server is running with the --skip-grant-tables option so it cannot execute this statement

    4.插入root用户
    mysql> insert into user(host,user,password,ssl_cipher,x509_issuer,x509_subject) values('localhost','root',PASSWORD('123'),'','','');

    insert into mysql.user values ('localhost','root',PASSWORD('123'),
    'Y',
    'Y',
    'Y',
    'Y',
    'Y',
    'Y',
    'Y',
    'Y',
    'Y',
    'Y',
    'Y',
    'Y',
    'Y',
    'Y',
    'Y',
    'Y',
    'Y',
    'Y',
    'Y',
    'Y',
    'Y',
    'Y',
    'Y',
    'Y',
    'Y',
    'Y',
    'Y',
    'Y',
    'Y',
    '',
    '',
    '',
    '',0,0,0,0,'mysql_native_password','','N');

    (不好的地方要加--skip-networking,不然数据其他人也能通过远程连接进入数据库,让数据不安全)

    方法二:

    (刷新,数据库)

    mysql> flush privileges;

    Query OK, 0 rows affected (0.00 sec)

    mysql> grant all on *.* to root@'localhost' identified by '123';
    Query OK, 0 rows affected (0.00 sec)

    授权超级用户
    grant all on *.* to root@'localhost' identified by '123' with grant option;

  • 相关阅读:
    移动端和pc端的判断,不同端做不同的处理
    easyUI combobox的使用
    [Codeforces #196] Tutorial
    [Codeforces #174] Tutorial
    [Codeforces #190] Tutorial
    [Codeforces #211] Tutorial
    [Codeforces #192] Tutorial
    [BZOJ 3196] 二逼平衡树
    [BZOJ 1058] 报表统计
    [P3709] 大爷的字符串题
  • 原文地址:https://www.cnblogs.com/sudaguo/p/10840543.html
Copyright © 2020-2023  润新知