1、查看某个用户的权限
--查看某个用户的权限
show grants; --查看root用户的权限
show grants for 'stc1'; --查看stc1用户的权限
2、授权stc用户远程登录test库,并授予所有的执行权限
grant all privileges on stc.* to 'stc'@'%' identified by 'ppp';
3、授予stc1用户远程登录test库,并授予只能使用select、insert权限
grant select,insert on test.* to 'stc1'@'%' identified by 'ppp';
4、更新stc1的权限
-- 登录到MySQL
mysql -u root -p-- 选择mysql数据库
USE mysql;-- 更新特定用户的权限(以下示例中,将用户'example_user'的权限更新为拥有所有数据库的完全权限)
UPDATE user SET Grant_priv='Y' WHERE User='example_user';
FLUSH PRIVILEGES;-- 或者直接通过一个命令更新权限(以下示例中,将用户'example_user'的密码更改为'new_password'并赋予所有数据库的完全权限)
GRANT ALL PRIVILEGES ON *.* TO 'example_user'@'%' IDENTIFIED BY 'new_password';
FLUSH PRIVILEGES;-- 退出MySQL
EXIT;
5、权限回收
--格式:revoke 权限列表 on 数据库名.表名 from '用户名'@'主机名';
revoke select on test.* from 'stc1';