桂林北站附近酒店,开发公司自平衡,台州网页设计招聘信息,diy手工制作网站2019独角兽企业重金招聘Python工程师标准 相关参考资料#xff1a;MySQL 赋予用户权限命令的简单格式可概括为#xff1a;grant 权限 on 数据库对象 to 用户一、grant 普通数据用户#xff0c;查询、插入、更新、删除 数据库中所有表数据的权利。 grant s… 2019独角兽企业重金招聘Python工程师标准 相关参考资料MySQL 赋予用户权限命令的简单格式可概括为grant 权限 on 数据库对象 to 用户一、grant 普通数据用户查询、插入、更新、删除 数据库中所有表数据的权利。 grant select on testdb.* to common_user%grant insert on testdb.* to common_user%grant update on testdb.* to common_user%grant delete on testdb.* to common_user%或者用一条 MySQL 命令来替代grant select, insert, update, delete on testdb.* to common_user%二、grant 数据库开发人员创建表、索引、视图、存储过程、函数。。。等权限。grant 创建、修改、删除 MySQL 数据表结构权限。grant create on testdb.* to developer192.168.0.%;grant alter on testdb.* to developer192.168.0.%;grant drop on testdb.* to developer192.168.0.%;grant 操作 MySQL 外键权限。grant references on testdb.* to developer192.168.0.%;grant 操作 MySQL 临时表权限。grant create temporary tables on testdb.* to developer192.168.0.%;grant 操作 MySQL 索引权限。grant index on testdb.* to developer192.168.0.%;grant 操作 MySQL 视图、查看视图源代码 权限。grant create view on testdb.* to developer192.168.0.%;grant show view on testdb.* to developer192.168.0.%;grant 操作 MySQL 存储过程、函数 权限。grant create routine on testdb.* to developer192.168.0.%; -- now, can show procedure statusgrant alter routine on testdb.* to developer192.168.0.%; -- now, you can drop a proceduregrant execute on testdb.* to developer192.168.0.%;三、grant 普通 DBA 管理某个 MySQL 数据库的权限。grant all privileges on testdb to dbalocalhost其中关键字 “privileges” 可以省略。四、grant 高级 DBA 管理 MySQL 中所有数据库的权限。grant all on *.* to dbalocalhost五、MySQL grant 权限分别可以作用在多个层次上。1. grant 作用在整个 MySQL 服务器上grant select on *.* to dbalocalhost ; -- dba 可以查询 MySQL 中所有数据库中的表。grant all on *.* to dbalocalhost ; -- dba 可以管理 MySQL 中的所有数据库 2. grant 作用在单个数据库上grant select on testdb.* to dbalocalhost ; -- dba 可以查询 testdb 中的表。3. grant 作用在单个数据表上grant select, insert, update, delete on testdb.orders to dbalocalhost ;4. grant 作用在表中的列上grant select(id, se, rank) on testdb.apache_log to dbalocalhost ;5. grant 作用在存储过程、函数上grant execute on procedure testdb.pr_add to dbalocalhostgrant execute on function testdb.fn_add to dbalocalhost六、查看 MySQL 用户权限查看当前用户自己权限show grants;查看其他 MySQL 用户权限show grants for dbalocalhost;七、撤销已经赋予给 MySQL 用户权限的权限。revoke 跟 grant 的语法差不多只需要把关键字 “to” 换成 “from” 即可grant all on *.* to dbalocalhost;revoke all on *.* from dbalocalhost;八、MySQL grant、revoke 用户权限注意事项1. grant, revoke 用户权限后该用户只有重新连接 MySQL 数据库权限才能生效。2. 如果想让授权的用户也可以将这些权限 grant 给其他用户需要选项 “grant option“grant select on testdb.* to dbalocalhost with grant option;这个特性一般用不到。实际中数据库权限最好由 DBA 来统一管理。 ----------------------------------------------------------------------------------------------授权命令GRANT 语句的语法如下GRANT privileges (columns)ON whatTO user IDENTIFIEDBY passwordWITH GRANT OPTION对用户授权mysqlgrant rights on database.* to userhost identified by pass;例1:增加一个用户test1密码为abc让他可以在任何主机上登录并对所有数据库有查询、插入、修改、删除的权限。grant select,insert,update,delete on *.* to test1% Identified by abc;ON 子句中*.* 说明符的意思是“所有数据库所有的表”例2:增加一个用户test2密码为abc, 让他只可以在localhost上登录并可以对数据库mydb进行查询、插入、修改、删除的操作。grant select,insert,update,delete on mydb.* to test2localhost identified by abc;例子3增加一个用户custom他能从主机localhost、server.domain和whitehouse.gov连接。他只想要从 localhost存取bankaccount数据库从whitehouse.gov存取expenses数据库和从所有3台主机存取customer 数据库。他想要从所有3台主机上使用口令stupid。为了使用GRANT语句设置个用户的权限运行这些命令shell mysql --userroot mysqlmysql GRANT SELECT,INSERT,UPDATE,DELETE,CREATE,DROPON bankaccount.* TO customlocalhost IDENTIFIED BY stupid;mysql GRANT SELECT,INSERT,UPDATE,DELETE,CREATE,DROPON expenses.* TO customwhitehouse.gov IDENTIFIED BY stupid;mysql GRANT SELECT,INSERT,UPDATE,DELETE,CREATE,DROPON customer.* TO custom% IDENTIFIED BY stupid;权限信息用user、db、host、tables_priv和columns_priv表被存储在mysql数据库中(即在名为mysql的数据库中)。权限 列 Contextselect Select_priv 表insert Insert_priv 表update Update_priv 表delete Delete_priv 表index Index_priv 表alter Alter_priv 表create Create_priv 数据库、表或索引drop Drop_priv 数据库或表grant Grant_priv 数据库或表references References_priv 数据库或表reload Reload_priv 服务器管理shutdown Shutdown_priv 服务器管理process Process_priv 服务器管理file File_priv 在服务器上的文件存取1.select、insert、update和delete权限 允许你在一个数据库现有的表上实施操作是基本权限2.alter权限允许你使用ALTER TABLE3.create和drop权限允许你创建新的数据库和表或抛弃(删除)现存的数据库和表 如果你将mysql数据库的drop权限授予一个用户该用户能抛弃存储了MySQL存取权限的数据库4.grant权限允许你把你自己拥有的那些权限授给其他的用户。你不能明显地指定一个给定用户应该被拒绝存取。即你不能明显地匹配一个用户并且然后拒绝连接。你不能指定一个用户有权创建立或抛弃一个数据库中的表也不能创建或抛弃数据库本身。 可以同时列出许多被授予的单个权限。例如如果想让用户能读取和修改已有表的内容但又不允许创建新表或删除表可按如下授权GRANT SELECT,INSERT,DELETE,UPDATE ON samp_db.* TO user% IDENTIFIEDBY pass以上是我从别的地方拷贝过来后稍作修改的文字下面自己写一些需要注意的东西。为什么使用了Grant all on db.* to user identified by pass后在主机上访问数据库还会出现ERROR 1045 (28000): Access denied for user userlocalhost (using password: YES) 的错误提示解答方法如下运行命令 Grant all on db.* to userlocalhost identified by pass原因是当不加选项时效果与加%是一样的%从名义上包括任何主机%必须加上引号不然与放在一起可能不会被辨认出。不过有些时候有些版本%不包括localhost要单独对localhost进行赋值。 转载于:https://my.oschina.net/u/2331760/blog/390407