Mysql 用户的权限管理
用户-------------->服务器。
分为2个阶段
1: 你有没有权连接上来
2 : 你有没有权执行操作(如 select update 等)
对于 1 服务器如何判断用户有没有权限连接上来?
依据三个参数
1 你从哪里来 ? host
2 你是谁 ? username
3 你的密码是多少? password
用户的这三个信息存放在mysql 库下的user 表中。
------flush privileges 刷新权限。
修改 host 域 使 ip可以连接
update user set host =' 192.168.1.101' where user = 'root'
如何修改用户的密码
update user set password = password('111111') where user = xxxx;
flush privileges;
2 . 用户权限
-----新增用户
grant [权限1,权限2,权限3,...] on *.*(那个数据库下的那张表) to user@'host'
identfied by 'password' ;
常用权限有 all create drop,delete,update,select
设置权限
grant all on *.* to lisi@'192.168.1.101'; identified by '111111';
收回权限
revoke all on *.* from list@'192.168.1.1'
当用户连接后,
判断 用户有没有全局数据库的操作权限如果没有,则查询有没有某一
个数据库的操作权限,如果没有继续查询有没有某张表的操作权限。