mysql 授权命令
MySQL 数据库赋予用户权限操作表
MySQL清空数据库的操作:truncate table tablename;
MySQL 赋予用户权限命令的简单格式可概括为:grant 权限 on 数据库对象 to 用户
一、grant 普通数据用户,查询、插入、更新、删除 数据库中所有表数据的权利。
1 grant select on testdb.* to common_user@'%' grant insert on testdb.* to common_user@'%' grant update on testdb.* to common_user@'%' grant delete on testdb.* to common_user@'%'
2 或者,用一条 MySQL 命令来替代:
3 grant select, insert, update, delete on testdb.* to common_user@'%'
二、grant 数据库开发人员,创建表、索引、视图、存储过程、函数。。。等权限。
grant 创建、修改、删除 MySQL 数据表结构权限
1 grant create on testdb.* to developer@'192.168.0.%' ;
2 grant alter on testdb.* to developer@'192.168.0.%' ;
3 grant drop on testdb.* to developer@'192.168.0.%' ;
grant 操作 MySQL 外键权限
grant references on testdb.* to developer@'192.168.0.%' ;
grant 操作 MySQL 临时表权限
grant create temporary tables on testdb.* to developer@'192.168.0.%' ;
grant 操作 MySQL 索引权限
grant index on testdb.* to developer@'192.168.0.%' ;
grant 操作 MySQL 视图、查看视图源代码权限
grant create view on testdb.* to developer@'192.168.0.%' ;
grant show view on testdb.* to developer@'192.168.0.%' ;
grant 操作 MySQL 存储过程、函数权限
1 grant create routine on testdb.* to developer@'192.168.0.%' ; -- now, can show procedure status
2 grant alter routine on testdb.* to developer@'192.168.0.%' ; -- now, you can drop a procedure
3 grant execute on testdb.* to developer@'192.168.0.%' ;
三、grant 普通 DBA 管理某个 MySQL 数据库的权限
grant all privileges on testdb to dba@'localhost' 其中,关键字 “privileges” 可以省略。
四、grant 高级 DBA 管理 MySQL 中所有数据库的权限
grant all on *.* to dba@'localhost'
五、MySQL grant 权限,分别可以作用在多个层次上
1. grant 作用在整个 MySQL 服务器上:
grant select on *.* to dba@localhost ; -- dba 可以查询 MySQL 中所有数据库中的表。
grant all on *.* to dba@localhost ; -- dba 可以管理 MySQL 中的所有数据库
2. grant 作用在单个数据库上:
grant select on testdb.* to dba@localhost ; -- dba 可以查询 testdb 中的表。
3. grant 作用在单个数据表上:
grant select, insert, update, delete on testdb.orders to dba@localhost ;
4. grant 作用在表中的列上:
grant select(id, se, rank) on testdb.apache_log to dba@localhost ;
5. grant 作用在存储过程、函数上:
grant execute on procedure testdb.pr_add to 'dba'@'localhost'
grant execute on function testdb.fn_add to 'dba'@'localhost'
六、查看 MySQL 用户权限 查看当前用户(自己)权限: show grants;
查看其他 MySQL 用户权限: show grants for dba@localhost;
七、撤销已经赋予给 MySQL 用户权限的权限
revoke 跟 grant 的语法差不多,只需要把关键字 “to” 换成 “from” 即可:
grant all on *.* to dba@localhost;
revoke all on *.* from dba@localhost;
八、MySQL grant、revoke 用户权限注意事项
1. grant, revoke 用户权限后,该用户只有重新连接 MySQL 数据库,权限才能生效。
2. 如果想让授权的用户,也可以将这些权限 grant 给其他用户,需要选项 “grant option“
grant select on testdb.* to dba@localhost with grant option; 这个特性一般用不到。实际中,数据库权限最好由 DBA 来统一管理。
九 . FLUSH PRIVILEGES; 这样权限才会生效 不然要重新连接数据库 或者重启数据库
mysql 授权命令的更多相关文章
- MySQL授权命令grant的使用方法
本文实例,运行于 MySQL 5.0 及以上版本. MySQL 赋予用户权限命令的简单格式可概括为: grant 权限 on 数据库对象 to 用户 一.grant 普通数据用户,查询.插入.更新.删 ...
- MySQL授权命令grant的详细使用方法
2019-01-07 转自 https://www.cnblogs.com/crxis/p/7044582.html 本文实例,运行于 MySQL 5.0 及以上版本. MySQL 赋予用户权限命令的 ...
- 十六、MySQL授权命令grant的使用方法
MySQL 赋予用户权限命令的简单格式可概括为: grant 权限 on 数据库对象 to 用户 一.grant 普通数据用户,查询.插入.更新.删除 数据库中所有表数据的权利. grant sele ...
- MySQL数据库grant授权命令
MySQL数据库grant授权命令 制作人:全心全意 grant授权命令的使用 grant授权命令使用语法: grant 权限 on 数据库对象 to 用户 grant 权限 on 数据库对象 to ...
- 烂泥:mysql帮助命令使用说明
本文由秀依林枫提供友情赞助,首发于烂泥行天下. 在安装.管理和使用mysql过程中,你是不是需要记忆很多的mysql命令.而且对于新手来说,很不多的命令不知道该如何应用,对于老手来说很多命令时间长了忘 ...
- mysql常用命令(3)
一.启动与关闭 1.1 Linux下启动mysql 的命令: a. rpm包安装:service mysqld start b. 源码包安装:/usr/local/mysql/bin/mysqld_s ...
- MYSQL常用命令集合(转载)
文章出处:http://www.cnblogs.com/q1ng/p/4474501.html 1.导出整个数据库mysqldump -u 用户名 -p --default-character-set ...
- MYSQL常用命令集合
1.导出整个数据库 mysqldump -u 用户名 -p --default-character-set=latin1 数据库名 > 导出的文件名(数据库默认编码是latin1) mysqld ...
- Mysql常用命令 详细整理版
Mysql常用命令 show databases; 显示数据库 create database name; 创建数据库 use databasename; 选择数据库 drop database na ...
随机推荐
- [UE4]Size To content自动适配大小
- Idea 2018版破解
刚把idea升级到最新版,发现要重新激活,网上查了有改host的方法可行,只是有点麻烦.无意中发现一个方法,如图所示 输入 http://idea.java.sx/ 即可,亲测可用.如果资金 ...
- 家庭版Windows设置远程连接
家庭版Windows设置远程连接1. windows+R 打开运行,输入 regedit 打开注册表 2.依次打开路径 计算机\HKEY_LOCAL_MACHINE\SOFTWARE\Microsof ...
- 舞蹈链(DLX)
舞蹈链(DLX) Tags:搜索 作业部落 评论地址 一.概述 特别特别感谢这位童鞋His blog 舞蹈链是一种优美的搜索,就像下面这样跳舞- 舞蹈链用于解决精确覆盖或者重复覆盖的问题 你可以想象成 ...
- django-response对象
HttpResponse 对象则需要 web 开发者自己创建,一般在视图函数中 return 回去.下面我们就来看看 HttpResponse 对象的各种细节 首先,这个对象由 HttpRespons ...
- ViewPager的addOnPageChangeListener和setOnPageChangeListener的区别,ViewPager改变数据后IndexOutOfBoundsException
我的ViewPager数据改变后,在切换界面刷新数据时:OnPageChangeListener中的数据IndexOutOfBoundsException,我们来看源码探一下究竟: 代码时这样写的: ...
- parameterized之unittest参数化
unittest没有想testNG那么方便,可以进行参数化,但是有一个第三方库可是实现参数化 安装 pip install parameterized 该库可以在python的所有单元测试框架中使用 ...
- uva-10700-贪心
题意:对于一个只有加法和乘法的序列,没有加法和乘法的优先级,问,结果最大值和最小值是多少,数字范围 1<=N <= 20 解题思路: (A+B)*C - (A+(B*C)) = AC + ...
- python 读取bin文件
python读取bin文件并下发串口 # coding:utf-8import time, serialfrom struct import *import binascii file = ope ...
- Java序列化对象-字符串转换
package com.test; import com.alibaba.fastjson.JSON; import org.junit.Test; import java.io.ByteArrayI ...