1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56
|
INSERT,SELECT, UPDATE, DELETE, CREATE, DROP, RELOAD, SHUTDOWN, PROCESS, FILE, REFERENCES, INDEX, ALTER, SHOW DATABASES, SUPER, CREATE TEMPORARY TABLES, LOCK TABLES, EXECUTE, REPLICATION SLAVE, REPLICATION CLIENT, CREATE VIEW, SHOW VIEW, CREATE ROUTINE, ALTER ROUTINE, CREATE USER, EVENT, TRIGGER, CREATE TABLESPACE
mysql> grant all on *.* to test@'10.0.0.%' identified by '123'; mysql> grant all privileges on *.* to test@'10.0.0.%' identified by '123'; 权限 作用对象 归属 密码
想要用户有grant权限 ,需要在授权命令的后面加:with grant option
mysql> grant all on *.* to aaa@'10.0.0.%' identified by '123';
mysql> show grants for aaa@'10.0.0.%'; +--------------------------------------------------------------------------------------------------------------------+ | Grants for aaa@10.0.0.% | +--------------------------------------------------------------------------------------------------------------------+ | GRANT ALL PRIVILEGES ON *.* TO 'aaa'@'10.0.0.%' IDENTIFIED BY PASSWORD '*23AE809DDACAF96AF0FD78ED04B6A265E05AA257' | +--------------------------------------------------------------------------------------------------------------------+
*.* [当前MySQL实例中所有库下的所有表] wordpress.* [当前MySQL实例中wordpress库中所有表(单库级别)]#常用的级别 wordpress.user [当前MySQL实例中wordpress库中的user表(单表级别)] 单字段级别
INSERT,SELECT, UPDATE, DELETE
INSERT,SELECT, UPDATE
比如一个表里面有用户的银行卡号,开发使用这个表,我不想让他看到表里面的银行卡信息,这个时候可以使用脱敏
mysql> grant insert,select(user,host),update,delete on mysql.user to dev@'localhost' identified by '123';
[root@db02 ~]# mysql -udev -p123 mysql> select user,host from mysql.user; +------+-------------+ | user | host | +------+-------------+ | aaa | 10.0.0.% | | root | db02 | | dev | localhost | | root | localhost | +------+-------------+ 8 rows in set (0.00 sec)
mysql> select user,host,password from mysql.user; ERROR 1143 (42000): SELECT command denied to user 'dev'@'localhost' for column 'password' in table 'user'
|