当前位置:网站首页>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、测试连接
边栏推荐
- 《命令行上的数据科学第二版》校对活动重新启动
- PostgreSQLSQL高级技巧透视表
- 繁華落盡、物是人非:個人站長該何去何從
- 抖音实战~评论数量同步更新
- 【烹饪记录】--- 青椒炒千张
- MD5 tool class
- NFT insider 64: e-commerce giant eBay submitted an NFT related trademark application, and KPMG will invest $30million in Web3 and metauniverse
- Visual task scheduling & drag and drop | scalph data integration based on Apache seatunnel
- Locust performance test - environment construction and use
- 力扣_回文数
猜你喜欢
都说软件测试很简单有手就行,但为何仍有这么多劝退的?
AscendEX 上线 Walken (WLKN) - 一款卓越领先的“Walk-to-Earn”游戏
Common open source codeless testing tools
NFT Insider #64:电商巨头eBay提交NFT相关商标申请,毕马威将在Web3和元宇宙中投入3000万美元
Concurrent optimization summary
UML图记忆技巧
Introduction and application of bigfilter global transaction anti duplication component
[Yugong series] go teaching course 003-ide installation and basic use in July 2022
The use of complex numbers in number theory and geometry - Cao Zexian
常用的开源无代码测试工具
随机推荐
Google Earth Engine(GEE)——以MODIS/006/MCD19A2为例批量下载逐天AOD数据逐天的均值、最大值、最小值、标准差、方差统计分析和CSV下载(北京市各区为例)
LOGO特训营 第五节 字体结构与设计常用技法
并发优化总结
Kdd2022 | what features are effective for interaction?
我在linux里面 通过调用odspcmd 查询数据库信息 怎么静默输出 就是只输出值 不要这个
[Yugong series] go teaching course 003-ide installation and basic use in July 2022
Force buckle 2_ 1480. Dynamic sum of one-dimensional array
MySQL存储数据加密
Concurrent optimization summary
Nat. Commun.| Machine learning jointly optimizes the affinity and specificity of mutagenic therapeutic antibodies
Challenges faced by virtual human industry
都说软件测试很简单有手就行,但为何仍有这么多劝退的?
Recommendation of mobile app for making barcode
LOGO特训营 第一节 鉴别Logo与Logo设计思路
记录:关于Win10系统中Microsoft Edge上的网页如何滚动截屏?
leetcode 72. Edit Distance 编辑距离(中等)
抖音实战~评论数量同步更新
UML diagram memory skills
Introducing QA into the software development lifecycle is the best practice that engineers should follow
Force buckle_ Palindrome number