博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
MySQL创建及授权账号
阅读量:2337 次
发布时间:2019-05-10

本文共 1673 字,大约阅读时间需要 5 分钟。

用户的定义

用户名@‘白名单’

wordpress@’%’

wordpress@‘localhost’
wordpress@‘127.0.0.1’
wordpress@‘10.0.0.%’
wordpress@‘10.0.0.5%’
wordpress@‘10.0.0.0/255.255.254.0’
wordpress@‘10.0.%’

grant all on *.* to wen@"localhost" identified by "111111";

grant 授权命令(8.0版本之前可以自动创建用户并授权,8.0必须先创建在授权)

all 对应权限
on *.* 目标:库和表
to wen@“localhost” 用户名和客户端主机
identified by “111111” 用户密码

操作案例:创建master用户对test库具备所有权限,允许从localhost主机登录管理数据库,密码为master123

mysql> grant all on test.* to master@“localhost” identified by “master123”;
mysql> flush privileges;
授权后查看用户
mysql> select user,host from mysql.user;
查看授权用户权限
mysql> show grants for master@localhost;

额外添加管理员账号

grant all privileges on *.* to gao@"localhost" identified by '111111' with grant option;

with grant option 这个参数表示gao这个用户有授权权限

mysql> flush privileges;
mysql> select user,host from mysql.user;
±-----±----------+
| user | host |
±-----±----------+
| root | 127.0.0.1 |
| gao | localhost |
| root | localhost |

撤销用户授权 revoke

revoke 跟 grant 的语法差不多,只需要把关键字 “to” 换成 “from” 即可:

1 grant  all on *.* to dba@localhost;  2 revoke all on *.* from dba@localhost;3 mysql> revoke delete on *.* from dba@localhost;  撤销dab账号delete权限4 mysql> revoke grant option on *.* dba@localhost;   #撤销授权权限

授权用户登录收修改自己的密码

set password=password(“新密码”)
数据库管理员重置授权用户密码
set password for 用户名@“ip”=password(“新密码”)

删除远程登录地址为10.125.192.6上面用户为root的用户,使其不能远程登录数据库服务器

mysql> delete from mysql.user
-> where
->user=“root” and host=“10.125.192.6”;
Query OK, 2 rows affected (0.00 sec)
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)

单独创建用户不授权

mysql> create user gao@localhost identified by ‘123’;

修改账号密码

alter user peng@’%’ identified by ‘123’;

删除账号

drop user gao@‘localhost’;

转载地址:http://skrpb.baihongyu.com/

你可能感兴趣的文章
Python爬虫工具篇 - 必会用的6款Chrome插件
查看>>
所谓的成长,就是不断破局,成长很痛苦,不成长也便没有了甘甜
查看>>
Python学习教程:python设置执行选项参数
查看>>
关于ASCII、Unicode、UTF-8编码问题的小思考
查看>>
2019最新Python爬虫面试高频率面试题总结(二)
查看>>
python函数专讲:exec执行函数
查看>>
python学习教程函数专讲:exec执行函数
查看>>
Python学习教程:使用Python批量修改数据库执行Sql文件
查看>>
Python:如何判断一个url是以http开头的?
查看>>
一个员工的离职成本,很恐怖
查看>>
Python学习教程:用Python模拟登录淘宝
查看>>
Python学习教程:成语查询工具 - 数据获取
查看>>
从事Python多年的全栈工程师给你分析为什么学Python
查看>>
Struts——资源文件加载到Container
查看>>
托管代码与非托管代码
查看>>
C++ 引用/指针/对象名调用
查看>>
C++~数组/指针
查看>>
Java 堆栈
查看>>
C++ 基本操作
查看>>
C++容器/迭代器
查看>>