当前位置:网站首页>MYSQL架构——用户权限与管理
MYSQL架构——用户权限与管理
2022-07-04 22:17:00 【swttws.】
目录
一、MYSQL用户管理
1、创建用户
create user lisi identified by '123456';
表示创建用户名为lisi,密码为123456的用户
2、了解用户user表
查询用户表特定字段
select host,user,authentication_string,select_priv,insert_priv,drop_priv from mysql.user;
(1)host表示连接类型
①%表示远程连接,其他机器可以通过该机器的IP地址进行连接;
②localhost表示本地连接,如mysql -u root -p;
(2)user表示用户名,同一用户不同连接方式权限不同
(3)select_priv , insert_priv为·用户权限
3、修改用户密码
(1)修改当前用户密码
set password =password('123456')
(2)修改某个用户密码,必须使用root用户修改
update mysql.user set authentication_string=password('111111') where user='lisi';
所有修改完用户表后,需要执行以下指令才能生效
flush privileges;
4、删除用户
drop user 'lisi';
注:不要使用以下语句删除,系统会有残留信息
delete from user where user='lisi'
二、权限管理
1、授权命令
授权命令需要在root用户下执行
grant 权限1,权限2,...,权限n on 数据库名.表名 to 用户名@用户地址 identified by 用户密码
如:
grant select,insert,delete,update on mytabl.* to [email protected] identified by ‘123456
该命令给lisi授予mytabl库下所有表的增删改查的权限,用户lisi必须存
2、收回权限
收回权限命令需要在root用户下执行
revoke 权限1,权限2,...,权限n on 数据库名.表名 to 用户名@用户地址
如:
REVOKE select,insert,update,delete ON *.* FROM [email protected]'%';
收回在lisi用户下,操作所有表的增删改查命令,执行完该指令后,需要lisi重新登录才有效
3、查看权限
(1)show grants:查看当前用户权限;
(2)查看某用户全局权限:
select * from mysql.user
三、远程访问
1、授予用户远程连接权限
grant all privileges on *.* to 用户@'%' identified by '密码';
2、先ping一下数据库IP地址
ping 数据库所在机器IP地址 -t
3、防火墙设置
(1)关闭防火墙
systemctl stop firewalld.service
(2)或者开放端口
firewall-cmd --add-port=3306/tcp --permanent #重启防火墙 firewall-cmd --reload
4、测试连接
边栏推荐
- LOGO特訓營 第一節 鑒別Logo與Logo設計思路
- leetcode 72. Edit Distance 编辑距离(中等)
- 都说软件测试很简单有手就行,但为何仍有这么多劝退的?
- idea中pom.xml依赖无法导入
- sqlserver对数据进行加密、解密
- 通过Go语言创建CA与签发证书
- Shell 脚本实现应用服务日志入库 Mysql
- Xiangjiang Kunpeng joined the shengteng Wanli partnership program and continued to write a new chapter of cooperation with Huawei
- 并发优化总结
- Microservices -- Opening
猜你喜欢
Convolutional neural network model -- lenet network structure and code implementation
A large number of virtual anchors in station B were collectively forced to refund: revenue evaporated, but they still owe station B; Jobs was posthumously awarded the U.S. presidential medal of freedo
2022-07-04:以下go语言代码输出什么?A:true;B:false;C:编译错误。 package main import “fmt“ func main() { fmt.Pri
Scala download and configuration
Redis sentinel simply looks at the trade-offs between distributed high availability and consistency
Logo Camp d'entraînement section 3 techniques créatives initiales
质量体系建设之路的分分合合
Domestic database chaos
Tiktok actual combat ~ the number of comments is updated synchronously
【愚公系列】2022年7月 Go教学课程 003-IDE的安装和基本使用
随机推荐
都说软件测试很简单有手就行,但为何仍有这么多劝退的?
Alibaba launched a new brand "Lingyang" and is committed to becoming a "digital leader"
关于栈区、堆区、全局区、文字常量区、程序代码区
SPSS安装激活教程(包含网盘链接)
UML图记忆技巧
Deployment of JVM sandbox repeater
In Linux, I call odspcmd to query the database information. How to output silently is to only output values. Don't do this
Concurrent network modular reading notes transfer
Solana链上应用Crema因黑客攻击停运
LOGO特训营 第一节 鉴别Logo与Logo设计思路
Business is too busy. Is there really no reason to have time for automation?
常用的开源无代码测试工具
Logo special training camp section III initial creative techniques
Visual task scheduling & drag and drop | scalph data integration based on Apache seatunnel
Mysql root 账号如何重置密码
The Sandbox 和数字好莱坞达成合作,通过人力资源开发加速创作者经济的发展
Xiangjiang Kunpeng joined the shengteng Wanli partnership program and continued to write a new chapter of cooperation with Huawei
Introduction and application of bigfilter global transaction anti duplication component
NFT insider 64: e-commerce giant eBay submitted an NFT related trademark application, and KPMG will invest $30million in Web3 and metauniverse
Recommendation of mobile app for making barcode