只给用户'xiaocong'@'%'授权update权限
grant update on dbt3.customer to 'xiaocong'@'%';
![](https://img-blog.csdnimg.cn/img_convert/d8b9749617fed5dc3c51965462c4bf9e.png)
show grants;
![](https://img-blog.csdnimg.cn/img_convert/f277634335ac2f4e7e41838a58bc1bb5.png)
用xiaocong用户连接数据库,然后队dbt3.customer表进行update操作
2.1先用root用户查询出dbt3.customer表的第一行记录
![](https://img-blog.csdnimg.cn/img_convert/257ede3649d144d0edbd1075bb64aa0f.png)
2.2然后进行update操作
update customer set c_nationkey = 15 where c_custkey = 1;
![](https://img-blog.csdnimg.cn/img_convert/35333d8992440edf7042408fc307d096.png)
2.3发现不能进行update操作,提示没有select权限对dbt3.customer表的c_custkey这个字段
给'xiaocong'@'%'授予select权限再进行操作
grant select on dbt3.customer to 'xiaocong'@'%';
![](https://img-blog.csdnimg.cn/img_convert/aa1bd88da5f1bb3f01cdec6708ce621f.png)
flush privileges;
show grants for 'xiaocong'@'%';
![](https://img-blog.csdnimg.cn/img_convert/b22f2599e7b043709d854cd2a4cc0130.png)
再次进行对dbt3.customer表update操作
update customer set c_nationkey = 15 where c_custkey = 1;
![](https://img-blog.csdnimg.cn/img_convert/f5c2cc98a482e4e4d4f786df8cee4696.png)
总结:为了执行UPDATE操作,用户还需要具有SELECT权限,以便从表中检索数据以进行更新。如果您只想允许用户执行特定的UPDATE操作,您可以使用WHERE子句限制更新的行。