mysql> grant usage on *.* to ‘p1′@’localhost’ identified by ‘123′; 该权限只能用于数据库登陆,不能执行任何操作;且usage权限不能被回收,也即REVOKE用户并不能删除用户。 2. select
必须有select的权限,才可以使用select table
点击(此处)折叠或打开
mysql> grant select on pyt.* to ‘p1′@’localhost’; mysql> select * from shop; 3. create 必须有create的权限,才可以使用create table
mysql> grant create on pyt.* to ‘p1′@’localhost’; 4. create routine 必须具有create routine的权限,才可以使用{create |alter|drop} {procedure|function}
mysql> grant create routine on pyt.* to ‘p1′@’localhost’; 当授予create routine时,自动授予EXECUTE, ALTER ROUTINE权限给它的创建者: mysql> show grants for ‘p1′@’localhost’;
+—————————————————————————+
Grants for p1@localhost
+————————————————————————–+
| GRANT USAGE ON *.* TO ‘p1′@’localhost’ IDENTIFIED BY PASSWORD ‘*23AE809DDACAF96AF0FD78ED04B6A265E05AA257′ |
| GRANT SELECT, CREATE, CREATE ROUTINE ON `pyt`.* TO ‘p1′@’localhost’|
| GRANT EXECUTE, ALTER ROUTINE ON PROCEDURE `pyt`.`pro_shop1` TO ‘p1′@’localhost’ |
ERROR 1221 (HY000): Incorrect usage of DB GRANT and GLOBAL PRIVILEGES
mysql> grant super on *.* to p1@localhost;
Query OK, 0 rows affected (0.01 sec)
初始化的app/admin账号权限
GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, EXECUTE ON *.* TO 'admin'@'%' IDENTIFIED BY PASSWORD 'asdfa'; GRANT SELECT, INSERT, UPDATE, DELETE, EXECUTE ON *.* TO 'app'@'%' IDENTIFIED BY PASSWORD