饿虎岗资源网 Design By www.oxmxm.com

用户权限管理主要有以下作用:
1. 可以限制用户访问哪些库、哪些表
2. 可以限制用户对哪些表执行SELECT、CREATE、DELETE、DELETE、ALTER等操作
3. 可以限制用户登录的IP或域名
4. 可以限制用户自己的权限是否可以授权给别的用户

一、用户授权

复制代码 代码如下:mysql> grant all privileges on *.* to 'yangxin'@'%' identified by 'yangxin123456' with grant option;
 "color: #800000"> "color: #800000"> "color: #800000"> "color: #800000"> "color: #3366ff">http://dev.mysql.com/doc/refman/5.7/en/privileges-provided.html

MySQL用户权限管理详解

二、刷新权限

对用户做了权限变更之后,一定记得重新加载一下权限,将权限信息从内存中写入数据库。

mysql> flush privileges;

三、查看用户权限

复制代码 代码如下:mysql> grant select,create,drop,update,alter on *.* to 'yangxin'@'localhost' identified by 'yangxin0917' with grant option;
mysql> show grants for 'yangxin'@'localhost';

MySQL用户权限管理详解

四、回收权限

删除yangxin这个用户的create权限,该用户将不能创建数据库和表。

mysql> revoke create on *.* from 'yangxin@localhost';
mysql> flush privileges;

五、删除用户

mysql> select host,user from user;
+---------------+---------+
| host   | user |
+---------------+---------+
| %    | root |
| %    | test3 |
| %    | yx  |
| 192.168.0.% | root |
| 192.168.0.% | test2 |
| 192.168.0.109 | test |
| ::1   | yangxin |
| localhost  | yangxin |
+---------------+---------+
8 rows in set (0.00 sec)
mysql> drop user 'yangxin'@'localhost';

六、用户重命名

shell> rename user 'test3'@'%' to 'test1'@'%';

七、修改密码

1> 更新mysql.user表

mysql> use mysql;
# mysql5.7之前
mysql> update user set password=password('123456') where user='root';
# mysql5.7之后
mysql> update user set authentication_string=password('123456') where user='root';
mysql> flush privileges;

2> 用set password命令

语法:set password for ‘用户名'@'登录地址'=password(‘密码')

mysql> set password for 'root'@'localhost'=password('123456');

3> mysqladmin

语法:mysqladmin -u用户名 -p旧的密码 password 新密码

mysql> mysqladmin -uroot -p123456 password 1234abcd

注意:mysqladmin位于mysql安装目录的bin目录下

八、忘记密码

1> 添加登录跳过权限检查配置

修改my.cnf,在mysqld配置节点添加skip-grant-tables配置

[mysqld]
skip-grant-tables

2> 重新启动mysql服务

shell> service mysqld restart

3> 修改密码

此时在终端用mysql命令登录时不需要用户密码,然后按照修改密码的第一种方式将密码修改即可。

MySQL用户权限管理详解

4> 还原登录权限跳过检查配置

将my.cnf中mysqld节点的skip-grant-tables配置删除,然后重新启动服务即可。

以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持。

饿虎岗资源网 Design By www.oxmxm.com
广告合作:本站广告合作请联系QQ:858582 申请时备注:广告合作(否则不回)
免责声明:本站资源来自互联网收集,仅供用于学习和交流,请遵循相关法律法规,本站一切资源不代表本站立场,如有侵权、后门、不妥请联系本站删除!
饿虎岗资源网 Design By www.oxmxm.com

RTX 5090要首发 性能要翻倍!三星展示GDDR7显存

三星在GTC上展示了专为下一代游戏GPU设计的GDDR7内存。

首次推出的GDDR7内存模块密度为16GB,每个模块容量为2GB。其速度预设为32 Gbps(PAM3),但也可以降至28 Gbps,以提高产量和初始阶段的整体性能和成本效益。

据三星表示,GDDR7内存的能效将提高20%,同时工作电压仅为1.1V,低于标准的1.2V。通过采用更新的封装材料和优化的电路设计,使得在高速运行时的发热量降低,GDDR7的热阻比GDDR6降低了70%。

更新日志