3:那么我们来创建一个测试账号test,授予表层级的权限.如下所示:
?
- mysql>?drop?user?test;?
- Query?OK,?0?rows?affected?(0.00?sec)?
- ??
- mysql>?flush?privileges;?
- Query?OK,?0?rows?affected?(0.00?sec)?
- ??
- mysql>?grant?all?on?MyDB.kkk?to?test@'%'?identified?by?'test';?
- Query?OK,?0?rows?affected?(0.01?sec)?
- ??
- mysql>??
- ??
- mysql>?show?grants?for?test;?
- +-----------------------------------------------------------------------------------------------------+?
- |?Grants?for?test@%???????????????????????????????????????????????????????????????????????????????????|?
- +-----------------------------------------------------------------------------------------------------+?
- |?GRANT?USAGE?ON?*.*?TO?'test'@'%'?IDENTIFIED?BY?PASSWORD?'*94BDCEBE19083CE2A1F959FD02F964C7AF4CFC29'?|?
- |?GRANT?ALL?PRIVILEGES?ON?`MyDB`.`kkk`?TO?'test'@'%'??????????????????????????????????????????????????|?
- +-----------------------------------------------------------------------------------------------------+?
- 2?rows?in?set?(0.00?sec)?
- ??
- mysql>?select?*?from?mysql.tables_priv\G;?
- ***************************?1.?row?***************************?
- ???????Host:?%?
- ?????????Db:?MyDB?
- ???????User:?test?
- ?Table_name:?kkk?
- ????Grantor:?root@localhost?
- ??Timestamp:?0000-00-00?00:00:00?
- ?Table_priv:?Select,Insert,Update,Delete,Create,Drop,References,Index,Alter,Create?View,Show?view,Trigger?
- Column_priv:??
- 1?row?in?set?(0.01?sec)?
- ??
- ERROR:??
- No?query?specified?
- ??
- mysql>??
4:那么我们来创建一个测试账号test,授予列层级的权限.如下所示:
?
- mysql>?drop?user?test;?
- Query?OK,?0?rows?affected?(0.00?sec)?
- ??
- mysql>?grant?select?(id,?col1)?on?MyDB.TEST1?to?test@'%'?identified?by?'test';?
- Query?OK,?0?rows?affected?(0.01?sec)?
- ??
- mysql>?flush?privileges;?
- Query?OK,?0?rows?affected?(0.00?sec)?
- ??
- mysql>??
- ??
- ??
- mysql>?select?*?from?mysql.columns_priv;?
- +------+------+------+------------+-------------+---------------------+-------------+?
- |?Host?|?Db???|?User?|?Table_name?|?Column_name?|?Timestamp???????????|?Column_priv?|?
- +------+------+------+------------+-------------+---------------------+-------------+?
- |?%????|?MyDB?|?test?|?TEST1??????|?id??????????|?0000-00-00?00:00:00?|?Select??????|?
- |?%????|?MyDB?|?test?|?TEST1??????|?col1????????|?0000-00-00?00:00:00?|?Select??????|?
- +------+------+------+------------+-------------+---------------------+-------------+?
- 2?rows?in?set?(0.00?sec)?
- ??
- mysql>?show?grants?for?test;?
- +-----------------------------------------------------------------------------------------------------+?
- |?Grants?for?test@%???????????????????????????????????????????????????????????????????????????????????|?
- +-----------------------------------------------------------------------------------------------------+?
- |?GRANT?USAGE?ON?*.*?TO?'test'@'%'?IDENTIFIED?BY?PASSWORD?'*94BDCEBE19083CE2A1F959FD02F964C7AF4CFC29'?|?
- |?GRANT?SELECT?(id,?col1)?ON?`MyDB`.`TEST1`?TO?'test'@'%'?????????????????????????????????????????????|?
- +-----------------------------------------------------------------------------------------------------+?
- 2?rows?in?set?(0.00?sec)?
- ??
- mysql>??
(编辑:ASP站长网)
|