如何使用MySQL角色管理
发表于:2025-11-07 作者:千家信息网编辑
千家信息网最后更新 2025年11月07日,这篇文章主要讲解了"如何使用MySQL角色管理",文中的讲解内容简单清晰,易于学习与理解,下面请大家跟着小编的思路慢慢深入,一起来研究和学习"如何使用MySQL角色管理"吧!1 配置 proxymys
千家信息网最后更新 2025年11月07日如何使用MySQL角色管理
这篇文章主要讲解了"如何使用MySQL角色管理",文中的讲解内容简单清晰,易于学习与理解,下面请大家跟着小编的思路慢慢深入,一起来研究和学习"如何使用MySQL角色管理"吧!
1 配置 proxy
mysql> show variables like "%proxy%"; #查看当前proxy是否开启,OFF 表示没有开启 +-----------------------------------+-------+ | Variable_name | Value | +-----------------------------------+-------+ | check_proxy_users | OFF | | mysql_native_password_proxy_users | OFF | | proxy_user | | | sha256_password_proxy_users | OFF | +-----------------------------------+-------+ 4 rows in set (0.02 sec) mysql> set global check_proxy_users =on; Query OK, 0 rows affected (0.00 sec) mysql> set global mysql_native_password_proxy_users = on; Query OK, 0 rows affected (0.01 sec) mysql> exit
以上设置参数,对当前会话无效,需要退出后重新登录,或直接设置到 my.cnf 中去;
2 创建角色和用户
mysql> create user role_dba; Query OK, 0 rows affected (1.03 sec) mysql> create user 'jack'; Query OK, 0 rows affected (0.01 sec) mysql> create user 'mary'; Query OK, 0 rows affected (0.01 sec)
用户为设置密码,如需密码可以使用 identified by '####' 设置;
3 权限映射
将 role_dba 的权限映射( map )到 jack 、mary
mysql> grant proxy on role_dba to jack; Query OK, 0 rows affected (0.02 sec) mysql> grant proxy on role_dba to mary; Query OK, 0 rows affected (0.01 sec)
4 给用户赋权
给 role_dba 赋权(模拟 role 赋权)
mysql> grant select on *.* to role_dba; Query OK, 0 rows affected (0.01 sec) mysql> show grants for role_dba; +---------------------------------------+ | Grants for role_dba@% | +---------------------------------------+ | GRANT SELECT ON *.* TO 'role_dba'@'%' | +---------------------------------------+ 1 row in set (0.00 sec) mysql> show grants for jack; +---------------------------------------------+ | Grants for jack@% | +---------------------------------------------+ | GRANT USAGE ON *.* TO 'jack'@'%' | | GRANT PROXY ON 'role_dba'@'%' TO 'jack'@'%' | +---------------------------------------------+ 2 rows in set (0.00 sec) mysql> show grants for mary; +---------------------------------------------+ | Grants for mary@% | +---------------------------------------------+ | GRANT USAGE ON *.* TO 'mary'@'%' | | GRANT PROXY ON 'role_dba'@'%' TO 'mary'@'%' | +---------------------------------------------+ 2 rows in set (0.00 sec)
5 查看 mysql.proxies_priv
mysql> select * from mysql.proxies_priv; +-----------+------+--------------+--------------+------------+----------------------+---------------------+ | Host | User | Proxied_host | Proxied_user | With_grant | Grantor | Timestamp | +-----------+------+--------------+--------------+------------+----------------------+---------------------+ | localhost | root | | | 1 | boot@connecting host | 0000-00-00 00:00:00 | | % | will | % | will_dba | 0 | root@localhost | 0000-00-00 00:00:00 | | % | tom | % | will_dba | 0 | root@localhost | 0000-00-00 00:00:00 | | % | jack | % | role_dba | 0 | root@localhost | 0000-00-00 00:00:00 | | % | mary | % | role_dba | 0 | root@localhost | 0000-00-00 00:00:00 | +-----------+------+--------------+--------------+------------+----------------------+---------------------+ 5 rows in set (0.01 sec)
6 验证
$ mysql -h 127.0.0.1 -u jack Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 249 Server version: 5.7.28-log MySQL Community Server (GPL) Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved. Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. mysql> select * from test.ssd limit 1; +---+------+------+ | a | b | c | +---+------+------+ | 1 | NULL | NULL | +---+------+------+ 1 row in set (0.01 sec)
感谢各位的阅读,以上就是"如何使用MySQL角色管理"的内容了,经过本文的学习后,相信大家对如何使用MySQL角色管理这一问题有了更深刻的体会,具体使用情况还需要大家实践验证。这里是,小编将为大家推送更多相关知识点的文章,欢迎关注!
角色
管理
用户
赋权
学习
内容
密码
权限
验证
参数
就是
思路
情况
文章
更多
知识
知识点
篇文章
跟着
问题
数据库的安全要保护哪些东西
数据库安全各自的含义是什么
生产安全数据库录入
数据库的安全性及管理
数据库安全策略包含哪些
海淀数据库安全审计系统
建立农村房屋安全信息数据库
易用的数据库客户端支持安全管理
连接数据库失败ssl安全错误
数据库的锁怎样保障安全
网络技术形容词
谷歌服务器未连接
安卓软件开发学生作品
服务器arm架构支持ocr吗
西安软件开发哪家靠谱
张家港营销网络技术哪家好
网络安全服务机构是哪个
我的世界怎么关掉服务器皮肤
大智慧行情服务器怎么修改
一加商店wifi没数据库
网络安全台账是什么意思
工业网络技术心得体会
检察网络安全防范
重庆恒建鑫网络技术有限公司
江西有哪些软件开发
金砖会议网络安全保障
天津商业大学网络安全于健康讲座
数据库应用技术形考任务实验答案
网络安全检测过程ppt
asa写人数据库
软件开发员用英语怎么说
用友t3的数据库怎么下载
上海伯程互联网科技有限公司
香港服务器安全工作
如何手动清空数据库中的数
数据库纳微
网络安全警察报警电话
娄底学数据库软件应用能力水平高
钉钉服务器异常请重新进入
数据库安全性课设指导书