MySQL 基础管理

时间:2022-01-30 04:57:29

#用户管理

  - 白名单设定

用户名@‘白名单‘
白名单支持的方式?
[email protected]‘10.0.0.%‘    
[email protected]‘%‘
[email protected]‘10.0.0.200‘
[email protected]‘localhost‘
[email protected]‘db02‘
[email protected]‘10.0.0.5%‘
[email protected]‘10.0.0.0/255.255.254.0‘

  - 创建用户

增:
mysql> create user [email protected]‘43.82.209.% identified by 123;
查:
mysql> desc mysql.user;
mysql> select user ,host ,authentication_string from mysql.user
改:
mysql> alter user [email protected]43.82.209.% identified by 456;
删:
mysql> drop user [email protected]43.82.209.%;

  - 授权

ALL:
  SELECT,INSERT, 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 ALL : 以上所有权限,一般是普通管理员拥有的 with grant option:超级管理员才具备的,给别的用户授权的功能
1 mysql> grant all on wordpress.* to [email protected]‘43.82.209.% identified  by 123;
    #grant:授权命令
    #all:权限
    #on: 作用命令
    #wordpress.*:权限的作用范围
      ##
        *.* --->全库.全表 管理员用户
        wordpress.* --->wordpress库 应用开发用户
        wordpress.t1
      ##
    #to: 作用命令

2 mysql> grant select ,update,insert,delete on app.* to [email protected]‘43.80.209.%‘ identified by ‘123‘;

    - 查看授权

1 mysql> show grants for [email protected]43.82.209.%;

   - 回收授权

1 mysql> revoke delete on app.* from [email protected]43.82.209.%;