当前位置:网站首页>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、测试连接

边栏推荐
- 华泰证券是国家认可的券商吗?开户安不安全?
- ApacheCN 翻译、校对、笔记整理活动进度公告 2022.7
- Challenges faced by virtual human industry
- php短视频源码,点赞时会有大拇指动画飘起
- 传智教育|如何转行互联网高薪岗位之一的软件测试?(附软件测试学习路线图)
- Zhiyang innovation signed a cooperation agreement with Huawei to jointly promote the sustainable development of shengteng AI industry
- Implementation rules for archiving assessment materials of robot related courses 2022 version
- POM in idea XML dependency cannot be imported
- 【Acwing】第58场周赛 题解
- 制作条形码的手机App推荐
猜你喜欢

质量体系建设之路的分分合合

Domestic database chaos

SPSS installation and activation tutorial (including network disk link)

Introduction and application of bigfilter global transaction anti duplication component

Embedded development: skills and tricks -- seven skills to improve the quality of embedded software code

达梦数据凭什么被称为国产数据库“第一股”?

常用的开源无代码测试工具

Convolutional neural network model -- lenet network structure and code implementation

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

Wake up day, how do I step by step towards the road of software testing
随机推荐
Nat. Commun.| Machine learning jointly optimizes the affinity and specificity of mutagenic therapeutic antibodies
Tiktok actual combat ~ the number of comments is updated synchronously
Now MySQL cdc2.1 is parsing the datetime class with a value of 0000-00-00 00:00:00
Locust performance test - environment construction and use
How diff are the contents of the same configuration item in different environments?
Scala下载和配置
传智教育|如何转行互联网高薪岗位之一的软件测试?(附软件测试学习路线图)
The use of complex numbers in number theory and geometry - Cao Zexian
HBuilder X 常用的快捷键
Scala download and configuration
ApacheCN 翻译、校对、笔记整理活动进度公告 2022.7
Shell script implements application service log warehousing MySQL
High school physics: linear motion
leetcode 72. Edit distance edit distance (medium)
阿里推出新品牌“瓴羊”,致力成为“数字化领头羊”
Interview essential leetcode linked list algorithm question summary, whole process dry goods!
How to manage 15million employees easily?
都说软件测试很简单有手就行,但为何仍有这么多劝退的?
Ascendex launched Walken (WLKN) - an excellent and leading "walk to earn" game
[cooking record] - stir fried 1000 pieces of green pepper
