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