300字范文,内容丰富有趣,生活中的好帮手!
300字范文 > mysql误删root用户

mysql误删root用户

时间:2023-05-23 21:15:45

相关推荐

mysql误删root用户

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

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

1、首先在/etc/f文件中 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/f文件上删除掉skip-grant-tables

重启mysql服务

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

重新初始化

schematool -initSchema -dbType mysql

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。