grant all privileges on 库.表 to '用户名'@'主机' identified by '密码';
flush privileges;
如果语句后带有with grant option
,则可以把授权的权限也给该用户,该用户就可以授权其他用户了。
grant all privileges on *.* to 'test'@'%' identified by 'testpwd';
flush privileges;
grant all privileges on *.* to 'test'@'192.168.1.8' identified by 'testpwd';
flush privileges;
grant all privileges on demo.* to 'test'@'%' identified by 'testpwd';
flush privileges;
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'; //查看指定用户权限
转载请注明出处: https://chrunlee.cn/article/mysql-privileges-ip.html