创建MySQL用户 赋予某指定库表的权限 flush privileges才能生效!!!!;@'localhost'授权本地,@'%'授权远程
update
ERROR 1364 (HY000): Field 'ssl_cipher' doesn't have a default value
建议使用GRANT语句进行授权,语句如下:
grant all privileges on *.* to root@'%' identified by "root";
---------------------------------------------------
GRANT SELECT,INSERT,UPDATE,DELETE,CREATE,DROP
ON maildb.*
TO 'mail'@'localhost'
IDENTIFIED by 'mailPASSWORD ';
创建snort数据库,创建snort用户,将snort库所有表的所有权限赋予用户snort。
mysql> create database snort;
Query OK, 1 row affected (0.06 sec)
创建数据库
mysql> use mysql;
进入mysql库
mysql> insert into user (Host,User,Password) values ("localhost","snort",PASSWORD("112233445566"));
创建用户,设置初始密码
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
使改动生效; 注:如果不执行该指令,则无法正常执行后续指令。
mysql> grant all on snort.* to 'snort'@'localhost' ; (授权本地)
mysql> grant all on snort.* to 'snort'@'%' ; (授权远程)
Query OK, 0 rows affected (0.00 sec)
将snort库的所有权限赋予 snort用户
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
使改动生效
mysql> show grants for snort@localhost;
+-------------------------------------------------------------------------------------+
| Grants for snort@localhost |
+-------------------------------------------------------------------------------------+
| GRANT USAGE ON *.* TO 'snort'@'localhost' IDENTIFIED BY PASSWORD '1e6b29186dd45e97' |
| GRANT ALL PRIVILEGES ON `snort`.* TO 'snort'@'localhost' |
+-------------------------------------------------------------------------------------+
2 rows in set (0.00 sec)
MySQL 赋予用户权限命令的简单格式可概括为:grant 权限 on 数据库对象 to 用户
一、grant 普通数据用户,查询、插入、更新、删除 数据库中所有表数据的权利。
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@'%'
或者,用一条 MySQL 命令来替代:
grant select, insert, update, delete on testdb.* to common_user@'%'
二、grant 数据库开发人员,创建表、索引、视图、存储过程、函数。。。等权限。
grant 创建、修改、删除 MySQL 数据表结构权限。
grant create on testdb.* to developer@'192.168.0.%' ;
grant alter on testdb.* to developer@'192.168.0.%' ;
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 存储过程、函数 权限。
grant create routine on testdb.* to developer@'192.168.0.%' ; -- now, can show procedure status
grant alter routine on testdb.* to developer@'192.168.0.%' ; -- now, you can drop a procedure
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 来统一管理。
创建MySQL用户 赋予某指定库表的权限 flush privileges才能生效!!!!;@'localhost'授权本地,@'%'授权远程的更多相关文章
- 创建MySQL用户 赋予某指定库表的权限
摘自: http://renxiangzyq.iteye.com/blog/763837 update ERROR 1364 (HY000): Field 'ssl_cipher' doesn't h ...
- MySQL给某个用户给某个库表设置权限
-- 用root(最高权限的用户)进行以下操作-- 创建数据库:emc_power CREATE DATABASE emc_power DEFAULT CHARACTER SET utf8 COLLA ...
- MySQL 如何只导出 指定的表 的表结构和数据 ( 转 )
MySQL 如何只导出 指定的表 的表结构和数据 ( 转 ) 2011-01-04 15:03:33 分类: MySQL MySQL 如何只导出 指定的表 的表结构和数据 导出更个库的表结构如下:my ...
- 12、创建mysql用户及赋予用户权限
1.通过help命令查看grant的用法: CREATE USER 'jeffrey'@'localhost' IDENTIFIED BY 'password'; GRANT ALL ON db1.* ...
- 给新创建的用户 赋予所有的权利 *.* 查看权限 删除用户 ---------DCL用户权限管理篇
第一步:进入数据库以后,先用 show databases; 再use mysql; 再 show tables; 再 select user,host from mysql.user; ...
- oracle 创建一个用户,只能访问指定的对象
1>创建一个ORACLE 的用户 create user username identified by pws; 2>给用户授权 grant connect,resource to us ...
- MySQL主从仅同步指定库
有两种方式,1.在主库上指定主库二进制日志记录的库或忽略的库: vim /etc/my.cnf ... binlog-do-db=xxxx 二进制日志记录的数据库 binlog-ignore-db=x ...
- linux下创建mysql用户和数据库,并绑定
Linux下输入命令: mysql -uroot -proot123 进入mysql后输入: 查看目前有哪些数据库存在:mysql> SHOW DATABASES; 创建数据库:create s ...
- 创建mysql 用户并限定其操作主机 和 数据库
参考链接 http://www.cnblogs.com/top5/archive/2010/09/14/1825571.html ******** GRANT ALL ON push.* TO pus ...
随机推荐
- (转)TensorFlow 入门
TensorFlow 入门 本文转自:http://www.jianshu.com/p/6766fbcd43b9 字数3303 阅读904 评论3 喜欢5 CS224d-Day 2: 在 Da ...
- perform-two-phase-commits/
https://docs.mongodb.com/manual/tutorial/perform-two-phase-commits/
- easyUI之window
window组件是一个可拖动.浮动的面板,用于显示信息.内容可用 href或ajax获取. window是一个显示窗口,同时也可以显示layout的功能(也就是创建复合的组合窗口),如 <div ...
- GridView 控制分页页码间距
来源:http://auv2009.blog.163.com/blog/static/68858712200992793853431/ 技巧1:在分页区中改变当前页码的样式或高亮显示页码 一个简单的办 ...
- OpenJudge计算概论-循环移动
/*=============================================================================== 循环移动 总时间限制: 1000ms ...
- pouchdb 安装使用
1. 安装: If you are on a Debian flavor of Linux (Ubuntu, Mint, etc.), you can install CouchDB with: $ ...
- 【转】vs2012 打包安装更改 setup.exe的图标
还是老外的文章给力 I'm not aware of any way to change the icon BEFORE building the project so that once the C ...
- JDBC - Oracle PreparedStatement (GeneratedKey kind) ArrayIndexOutOfBoundsException
问题: Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 12at oracle.jdbc. ...
- SqlServer数据库正在还原的解决办法
1)管理器不会主动刷新,需要手工刷新一下才能看到最新状态(性能方面的考虑) 2)很少情况下,恢复进程被挂起了.这个时候假设你要恢复并且回到可访问状态,要执行: RESTORE database ...
- android ANR
下面有两篇关于Android ANR的文章,感觉不错,分享一下! [Android实例] [Sundy系列]网上绝无仅有的Log分析教程及例子!android ANRhttp://blog.csdn. ...