当前位置:网站首页>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地址 -t3、防火墙设置
(1)关闭防火墙
systemctl stop firewalld.service(2)或者开放端口
firewall-cmd --add-port=3306/tcp --permanent #重启防火墙 firewall-cmd --reload
4、测试连接

边栏推荐
- The use of complex numbers in number theory and geometry - Cao Zexian
- 高中物理:直线运动
- 不同环境相同配置项的内容如何diff差异?
- leetcode 72. Edit Distance 编辑距离(中等)
- How to transfer to software testing, one of the high paying jobs in the Internet? (software testing learning roadmap attached)
- Flask 上下文详解
- Tla+ introductory tutorial (1): introduction to formal methods
- 制作条形码的手机App推荐
- It is said that software testing is very simple, but why are there so many dissuasions?
- 现在mysql cdc2.1版本在解析值为0000-00-00 00:00:00的datetime类
猜你喜欢

抖音实战~评论数量同步更新

Challenges faced by virtual human industry

Enabling digital economy Fuxin software attends the BRICs high level Forum on Sustainable Development

Tiktok actual combat ~ the number of comments is updated synchronously

NFT insider 64: e-commerce giant eBay submitted an NFT related trademark application, and KPMG will invest $30million in Web3 and metauniverse

Play with grpc - go deep into concepts and principles

将QA引入软件开发生命周期是工程师要遵循的最佳实践

Logo Camp d'entraînement section 3 techniques créatives initiales

More than 30 institutions jointly launched the digital collection industry initiative. How will it move forward in the future?

The use of complex numbers in number theory and geometry - Cao Zexian
随机推荐
Now MySQL cdc2.1 is parsing the datetime class with a value of 0000-00-00 00:00:00
UML diagram memory skills
将QA引入软件开发生命周期是工程师要遵循的最佳实践
达梦数据凭什么被称为国产数据库“第一股”?
Shell script implements application service log warehousing MySQL
2022-07-04: what is the output of the following go language code? A:true; B:false; C: Compilation error. package main import “fmt“ func main() { fmt.Pri
Solana链上应用Crema因黑客攻击停运
虚拟人产业面临的挑战
Energy momentum: how to achieve carbon neutralization in the power industry?
【愚公系列】2022年7月 Go教学课程 003-IDE的安装和基本使用
Alibaba launched a new brand "Lingyang" and is committed to becoming a "digital leader"
TLA+ 入门教程(1):形式化方法简介
Flask 上下文详解
Introduction and application of bigfilter global transaction anti duplication component
【Acwing】第58场周赛 题解
Short video system source code, click the blank space of the screen, the keyboard does not automatically stow
Common open source codeless testing tools
PostgreSQLSQL高级技巧透视表
Deployment of JVM sandbox repeater
AscendEX 上线 Walken (WLKN) - 一款卓越领先的“Walk-to-Earn”游戏
