MySQL5.7杂项(学习)

MySQL5.7杂项(学习)

误删root账户

1、停止mysql服务

net stop myqsl

2、在mysql根目录下的my.ini中添加字段

skip-grant-tables

3、启动mysql服务

net start mysql

4、免密登录后添加root用户

insert into user set user='root',ssl_cipher='',x509_issuer='',x509_subject='';

5、赋予权限

update user set Host='localhost',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';

6、修改密码

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

7、重启并登录mysql测试其是否添加成功

报错

1、ERROR 1290 (HY000): The MySQL server is running with the --skip-grant-tables option so it cannot execute this statement
因为添加了skip-grant-tables语句,所以无法进行修改操作。
解决方法:执行flush privileges;语句,再进行修改操作。

查看MySQL安装路径

  1. 登录MySQL
    在这里插入图片描述
  2. 输入命令:
show variables like "%char%";

在这里插入图片描述

刪除mysql服务

  1. 进入CMD
  2. sc delete mysql
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值