mysql常用命令,授权和撤销操作

授予数据库名称权限。
数据库表对用户的权限:insert添加、delete删除、select检查、update修改、create创建、delete删除。
示例:GrantSelectonusertoxhk表示授予用户数据库查询权限。
用户xhk您可以在“密码”标识的用户地址后添加@'ip,例如:grantallon*.*toxhk@'127.0.0.1'iden。
tifyby'123456'表示将所有数据库的所有权限授予用户xhk,允许用户xhk远程连接127.0.0.1的IP地址,并将用户的密码设置为123456。
刷新权限:flushprivileges//权限完成后,必须刷新权限才能生效。
普通用户通常添加、删除、检查更改:grantselectontest.*toxhk@'%'//指定测试数据库中所有表的查询权限。
aregranttouserxhkgrantinsertontest.usertoxhk@'%'//表示授予用户xhk对test数据库下user表的查询权限。
grantupdateontest.*toxhk@'%';、索引、视图权限、存储过程、函数等。
 :grantcreateontest.*toxhk@'192.168.0.%'grantalterontest.*toxhk@'192.168.0.%'grantdropontest.*toxhk@'192.168.0.%'//192.168.0.%表示允许的IP地址远程连接如果你想不限制IP地址。
链接,设置为'%'可以grantallprivilegesontestdbtodba@'localhost'其中关键字'privileges'可以省略grantallon*.*todba@'localhost'grantselecton*.*todba@localhost;--dba可以查询所有的表。
MySQL数据库grantallon*.*todba@localhost;--dba可以处理所有数据库。
MySQL中.grantselectontestdb.*todba@localhost;--dba可以对grantselect中的表进行查询、插入、更新、删除ontestdb.orderstodba@localhost;dba@localhost;grantexecuteonproceduretestdb.pr_addto'dba'@'localhost';grantexecuteonfunctiontestdb.fn_addto'dba'@'localhost';showgrants;showgrantsfordba@localhost;revokeallon*.*fromdba@localhost;grant,撤销用户权限后,用户只有重新连接MySQL数据库,以便grantselectontestdb.*todba@localhostwithgrantoption;这个功能一般不使用。
在实际应用中,数据库权限最好由数据库管理员统一管理。