MySQL:增加用户以及赋予不同的权限
2016-08-04 11:47
423 查看
在一个服务器上有多个数据库或者多个项目的时候,我们希望,每个项目的人,能否访问它的数据,而且对外提供服务的时候,如果也希望,尽量的安全考虑,尽量的只给需要的权限。
所以,我们打算给,每一个项目,它需要的最恰当的权限,来创建多个用户。
一.创建用户
创建的 jeffrey 用户可以在 mysql里面的mysql数据库,对应的user里面查到
我们在下面运行
mysql> select User from user where User = 'jeffrey';
+---------+
| User |
+---------+
| jeffrey |
+---------+
1 row in set (0.00 sec)
二.给刚才创建的用户给权限
grant
权限 on 数据库对象
to 用户
给jeffrey对db1数据库的所有数据操作权限
一、grant
普通数据用户,查询、插入、更新、删除 数据库中所有表数据的权利
grant
select
on db1.*
to 'jeffrey'@'%'
grant
insert
on
db1.*
to 'jeffrey'@'localhost'
grant
update
on
db1.*
to
'jeffrey'@'localho
4000
st'
grant
delete
on
db1.*
to
'jeffrey'@'localhost'
二、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 高级 DBA 管理 MySQL 中所有数据库的权限。
grant all on *db1.* to jeffrey@'localhost'
参考
http://dev.mysql.com/doc/refman/5.6/en/grant.html http://www.cnblogs.com/hcbin/archive/2010/04/23/1718379.html
获取更多的文章,欢迎关注微信公众号
所以,我们打算给,每一个项目,它需要的最恰当的权限,来创建多个用户。
一.创建用户
CREATE USER 'jeffrey'@'localhost' IDENTIFIED BY 'mypass';
创建的 jeffrey 用户可以在 mysql里面的mysql数据库,对应的user里面查到
我们在下面运行
mysql> select User from user where User = 'jeffrey';
+---------+
| User |
+---------+
| jeffrey |
+---------+
1 row in set (0.00 sec)
二.给刚才创建的用户给权限
MySQL 赋予用户权限命令的简单格式可概括为:
grant
权限 on 数据库对象
to 用户
GRANT ALL ON db1.* TO 'jeffrey'@'localhost';
给jeffrey对db1数据库的所有数据操作权限
一、grant
普通数据用户,查询、插入、更新、删除 数据库中所有表数据的权利
grant
select
on db1.*
to 'jeffrey'@'%'
grant
insert
on
db1.*
to 'jeffrey'@'localhost'
grant
update
on
db1.*
to
'jeffrey'@'localho
4000
st'
grant
delete
on
db1.*
to
'jeffrey'@'localhost'
二、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 高级 DBA 管理 MySQL 中所有数据库的权限。
grant all on *db1.* to jeffrey@'localhost'
参考
http://dev.mysql.com/doc/refman/5.6/en/grant.html http://www.cnblogs.com/hcbin/archive/2010/04/23/1718379.html
获取更多的文章,欢迎关注微信公众号
相关文章推荐
- MySQL的Grant命令详解
- 使用SKIP-GRANT-TABLES 解决 MYSQL ROOT密码丢失
- MySQL的Grant命令
- mysql中授权(grant)和撤销授权(revoke)等命令的用法详解
- mysql 的授权
- oracle数据库创建用户
- Oracle菜鸟之grant授权
- 建立 grant 用户权限 脚本
- MySQL: ERROR 1045 (28000) when GRANT
- MySQL创建用户与授权方法
- 管理用户
- Mysql的Grant命令
- 搞定linux上MySQL编程(五):MySQL权限管理
- Host '***' is not allowed to connect to this MySQL server"
- Mysql 用户权限
- MySQL root用户忘记密码解决方案(安全模式,修改密码的三种方式)
- mysql远程连接
- 解析grant connect, resource to user语句
- mysql 没有权限
- Oracle 复制scott下的表数据到另一用户下