日常小结:mysql权限----2018.1.17

权限:

  1. 高级用户   root 什么都可以用
  2. 创建用户(初级用户)

 

创建用户语法:

Create user 用户名字 identified by ‘密码’

(初始用户的权限很低的)

 

删除用户:

Drop user 用户名字;

 

在高级用户里面才能修改用户名字:

Rename user  老用户名字 to 新用户名字;

 

修改密码:

Set password=password();

 

高级用户里面修改密码:

Set  password for 用户名字=password(‘密码’);

 

授权:
1.查看用户权限:

Show grants for 用户名字;

2.给用户授权:

Grant 权限 on *.* to 用户;

*.* 所有库的意思,sun.*  sun库里面的所有表  sun.stu sun库里面的stu表)

 

取消用户权限:

Rebore 权限 on *.* from 用户名

 

刷新命令:

Flush privileges

索引

主键是唯一索引的。

 

索引:

  1. 唯一索引,这列不可有重复值(unique
  2. 聚集索引,没有明确索引,添加索引的时候是空白就是常规索引。
  3. 全文索引。
  4. 外键索引。

 

创建常规索引语法:

Create index 索引名字 on 表名(列名);

 

删除:

Drop index 索引名字 on 表名

 

创建唯一索引:

Create unique index 索引名字 on 表名(列名);

 

注:索引需求是你在编程的时候,条件上使用类的那个列,就可以将查询设计到的列设计为索引。

 

错误描述:

mysql> grant all on cactidb.* to dbuser@'localhost' identified by '123';

 

ERROR 1290 (HY000): The MySQL server is running with the --skip-grant-tables option so it cannot execute this statement

解决方法:

先刷新一下权限表。

mysql> flush privileges;

 

Query OK, 0 rows affected (0.01 sec)

 

mysql> grant all on cactidb.* to dbuser@'localhost' identified by '123';

 

Query OK, 0 rows affected (0.00 sec)

 

posted @ 2018-01-17 13:56  满小蛮  阅读(133)  评论(0)    收藏  举报