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

5268f80b9b1e01f982625ef6fac83ca1.png

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;

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

标签:his   local   values   password   误删   exec   ide   ssl   word

1428d0e076c3959ab11d28a39bc84fab.png

5268f80b9b1e01f982625ef6fac83ca1.png

本条技术文章来源于互联网,如果无意侵犯您的权益请点击此处反馈版权投诉

本文系统来源:https://www.cnblogs.com/sudaguo/p/10840543.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值