#查看用户
select user,host from mysql.user;(root,%),表示可以远程登录,并且是除服务器外的其他任何终端, 
如CREATE USER 'azkaban'@'192.168.79.10%' IDENTIFIED BY '123456';  #表192.168.79.101-109主机的azkaban用户. 如果是一个ip没有%则只表示这个主机来的用户
(root,localhost),表示可以本地登录,即可以在服务器上登陆
(root,127.0.0.1 ),表示可以本机登陆,即可以在服务器上登陆
(root,sv01),表示主机名为sv1可以登陆,sv01具体指的哪台机器,可以在cat /etc/hosts查看
(root,::1) ,表示本机可以登陆, 看密码都是相同嘛,具体::1代表意义,待查查看用户授权:
mysql> show grants for mysqld;#删除用户
drop user azkaban@'192.168.79.10%';
Grant授权:
建帐号和授权:
第一种方法:建用户,授权一条命令搞定
#在本地建帐号wordpress并赋予数据库test所有的权限
grant all on test.* to wordpress@'localhost' identified by '123456';
#允许172.16.1.xx网段的机器通过wordpress连接wordpress数据库,并拥有所有权限.
grant all on wordpress.* to wordpress@'172.16.1.%' identified by '123456';flush privileges;
第二种方法:
#先建用户;
CREATE USER 'jeffrey'@'localhost' IDENTIFIED BY 'mypass';
#把db1的所有权限赋予给本机的jeffrey用户
GRANT ALL ON db1.* TO 'jeffrey'@'localhost';
相当于第一种方法的; 
grant all on db1.* to jeffrey@'localhost' identified by 'mypass';
#刷新
flush privileges;例子:
CREATE USER 'azkaban'@'192.168.79.10%' IDENTIFIED BY 'azkaban';
给本地的root用访问所有数据库:
GRANT ALL PRIVILEGES ON *.* TO 'root'@'localhost';
给所有远程登陆的的root用户访问所有用户:
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%';
只赋予 SELECT、INSERT、UPDATE,DELETE 权限(一般给开发的权限)
 GRANT insert,delete,update,select ON test.* to 'dan'@'localhost';
如:创建新用户hf,可以从任何IP进行连接,权限为对mysql数据库里的所有表进行SELECT、INSERT、UPDATE,DELETE操作
grant select,insert,update,delete on mysql.* to 'hf'@'%'  identified by '123456';grant select,insert,update,delete on mine_test.* to 'zosapp'@'%'IDENTIFIED BY 'Zos2018' WITH GRANT OPTION;
 
生产环境主库
GRANT SELECT, INSERT, UPDATE, DELETE ON `blog`.* TO 'blog'@'172.16.1.%' identified by 'oldboy456';生产环境从库(只读)用户的授权:
GRANT SELECT ON `blog`.* TO 'blog'@'172.16.1.%' identified by 'oldboy456';

回收权限:

REVOKE INSERT ON *.* FROM 'jeffrey'@'localhost';
REVOKE CREATE,DROP ON *.* FROM 'hf'@'localhost';
REVOKE CREATE,DROP ON *.* FROM 'hf'@'%';
revoke all on *.* from dba@localhost;
#权限列表:
[root@db01 ~]# tr "," "\n" <a.log |sed 's#^ ##g'
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
 
简单建表测试命令:
 create table test(id INT(11));