mysql5.7 常用命令

查看数据库的所有用户

select user,host from mysql.user;

查看一下用户的权限 root

show grants for root@'%';

移除一个用户的插入权限

revoke INSERT on 库名.* from '用户名'@'%';

删除一个用户的远程权限

Delete from user where user = "用户名" and host = "%" ;

修改用户的远程权限

update user set host = 'localhost' where user = 'admin';

增加数据库的用户权限

grant select on  `库名`.* to '用户名'@'%';
GRANT ALL PRIVILEGES ON `库名`.* TO '用户名'@'%'

新建立一个用户,给一个库查看权限

grant select on 库名.* to '用户名'@'%' identified by '2bSXgc4*';

 

删除一个用户

删除用户:
>> delete from user where user='test' and host='localhost';
删除账户及权限:
>> drop user 用户名@'%';
>> drop user 用户名@ localhost; ;

root用户的访问设置

设置所有用户可以远程访问mysql,修改my.cnf配置文件,将bind-address = 127.0.0.1前面加“#”注释掉,这样就可以允许其他机器远程访问本机mysql了;
设置用户root,可以在远程访问mysql:
>> grant all privileges on *.* to root@"%" identified by "123456" ;
查询mysql中所有用户权限:
>> select host,user from user;
禁止root用户在远程机器上访问mysql:
>> delete from user where user="root" and host="%" ;

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值