只针对用户的操作命令:
mysql> create user zabbix@'10.0.0.%' identified by 'oldboy123';
Query OK, 0 rows affected (0.01 sec)
mysql> drop user root@'127.0.0.1';
Query OK, 0 rows affected (0.00 sec)
mysql> select user,host,password from mysql.user;
特殊的删除方法:
mysql> delete from mysql.user where user='oldboy' and host='localhost';
Query OK, 1 row affected (0.00 sec)
mysql> flush privileges;
2、用户授权
grant all on wordpress.* to workpress@'10.0.0.%' identified by 'oldboy123';
授权命令 权限 权限范围 用于 主机范围
开发用户权限:(root用户进行授权)
grant SELECT,INSERT, UPDATE, DELETE, CREATE, DROP on testdb.* to zabbix@'10.0.0.%';
使用zabbix检查:
mysql> create database testdb;
Query OK, 1 row affected (0.00 sec)
mysql> show databases;
创建用户并授权:
mysql> grant all on *.* to root@'10.0.0.%' identified by 'oldboy123';
Query OK, 0 rows affected (0.00 sec)
mysql> select user,host,password from mysql.user;
查询用户的权限:
mysql> show grants for zabbix@'10.0.0.%';
创建类似管理员:
mysql> show grants for root@'10.0.0.%';
本地超级管理员:有grants权限
mysql> show grants for root@'localhost';
收回权限:
mysql> revoke create,drop on testdb.* from zabbix@'10.0.0.%';
mysql> show grants for zabbix@'10.0.0.%';
思考:
grant select on *.* to zabbix@'10.0.0.%';
grant INSERT, UPDATE, DELETE, CREATE, DROP on testdb.* to zabbix@'10.0.0.%';
grant update on testdb.t1 to zabbix@'10.0.0.%';
###
mysql> use testdb;
mysql> create table t1(id int);
mysql> show tables;
mysql> insert into t1 values(1);