1.查看全部的用户:

select user,host from mysql.user\G; 

2.新建用户:

create user  ‘用户名’@‘主机名’  identified by ‘用户密码’;

3.Mysql用户权限:

ALL:所有可用的权限

CREATE:创建库、表以及索引

ALTER:修改表

DELETE:删除表

DROP:删除库、表和视图

INSERT:插入表或列

SELECT:检索表或列的数据

CREATE_VIEW:创建视图

SHOW_DATABASES:列出数据库

LOCK_TABLES:锁定表

4.用户授权

格式:  grant 权限 on 数据库.*  to 用户名@登录主机 identified by ‘密码’;

例如:

 //赋予所有权限

grant all privileges   on testDB.* to test@localhost identified by '1234'; 

//赋予部分权限       

grant select,update on testDB.* to test@localhost identified by '1234';

5.查看用户权限

show grants for ‘用户名’@‘主机名’

6.刷新系统权限表

flush privileges;

posted on 2018-11-12 15:52  影忧  阅读(6506)  评论(0编辑  收藏  举报