玖叶教程网

前端编程开发入门

mysql 赋权IP访问以及收回权限


通用写法

grant all privileges on 库.表 to '用户名'@'主机' identified by '密码'; flush privileges; 语句后带有with grant option ,可以把授权的权限也给该用户,该用户就可以授权其他用户了。

给用户 test 全部权限

grant all privileges on . to 'test'@'%' identified by 'testpwd'; flush privileges;

给用户 test 赋某个IP访问权限

grant all privileges on . to 'test'@'192.168.1.8' identified by 'testpwd'; flush privileges;

给用户test 赋予数据库 demo 的访问权限

grant all privileges on demo.* to 'test'@'%' identified by 'testpwd'; flush privileges; revoke 删除用户权限

通用写法

revoke 权限列表 on 库.表 from 用户名@'主机'; flush privileges;

删除用户所有权限

revoke all privileges on . from test@'%'; flush privileges;

删除用户某库权限

revoke all privileges on demo.* from test@'%'; flush privileges;

查看权限

show grants; //查看当前用户下所有权限 show grants for test@'192.168.1.8'; //查看指定用户权限

发表评论:

控制面板
您好,欢迎到访网站!
  查看权限
网站分类
最新留言