初识MySQL之——SQL语言基础
MariaDB> create user 'yzh'@'172.18.%.%'> 在mysql中用户账号由用户名和用户主机名组成。主机可以使用网段,通配符或者主机名,使用主机时要能与解析的ip相对应。MariaDB > setpassword for 'yzh'@'172.18.%.%'=password('123456'); 修改用户口令的正确姿势,不建议直接更改mysql.user表
MariaDB >grant select ,insert on Zachary.test to 'yzh'@'172.18.%.%'; 授予用户yzh对test表的查询和插入权限。
MariaDB >grant ALL on zachary.* to 'tony'@'localhost'> MariaDB> revoke insert on zachary.test from 'yzh'@'172.18.%.%'; 回收yzh用户在Zachary.test表的插入权限
MariaDB [(none)]> create user'test'@'localhost'> #mysql -u tony -p 使用tony用户连接
Enter password:
MariaDB >select user();
+----------------+
| user() |
+----------------+
| tony@localhost |
+----------------+
1 row in set (0.00 sec)
MariaDB> grant select on zachary.* to 'test'@'localhost';
使用tony用户授予test用户对Zachary数据库的查询操作。
#mysql -u root –p
MariaDB[(none)]> revoke all on zachary.* from 'tony'@'localhost';回收tony用户的所有权限,但是他授权的其他用户的权限不受影响。Revoke的权限不会级联回收
#mysql -u test -p #使用test用户仍旧能够查询
MariaDB[(none)]> select * from zachary.test;
+----+---------+------+---------------------+
|id | name | sex| email |
+----+---------+------+---------------------+
|1 | zachary | m | zachary_yzh@126.com |
|2 | marry | f | marry@163.com |
|3 | jack | m | jack@qq.com |
....
页:
[1]