mysql 创建新用户并添加权限
2015-09-10 16:20
866 查看
1、添加用户
1.1 添加一个新用户:
上面这种只支持mysql服务器本地登录。
1.2 添加一个任意Ip登录的用户:
2、授权test用户拥有testDB数据库的所有权限(某个数据库的所有权限):
2.1 为某个用户授予所有权限:
格式:grant 权限 on 数据库.* to 用户名@登录主机 identified by "密码";
2.2 为某个用户授予部分权限:
2.5 授权test用户拥有所有数据库的某些权限:
--test用户对所有数据库都有select,delete,update,create,drop 权限。
--@"%" 表示对所有非本地主机授权,不包括localhost。
--对localhost授权:加上一句grant all privileges on testDB.* to 'test'@'localhost' identified by '123456';即可。
1.1 添加一个新用户:
mysql>grant usage on *.* to 'sealy'@'localhost' IDENTIFIED by "123456" with grant option;
上面这种只支持mysql服务器本地登录。
1.2 添加一个任意Ip登录的用户:
mysql>grant usage on *.* to 'sealy'@'%' IDENTIFIED by "123456" with grant option;
2、授权test用户拥有testDB数据库的所有权限(某个数据库的所有权限):
2.1 为某个用户授予所有权限:
mysql>grant all privileges on testDB.* to 'test'@'%' identified by '123456'; mysql>flush privileges; --刷新系统权限表
格式:grant 权限 on 数据库.* to 用户名@登录主机 identified by "密码";
2.2 为某个用户授予部分权限:
mysql>grant select,update on 'testDB'.* to 'test'@'%' identified by '123456'; mysql>flush privileges;
2.5 授权test用户拥有所有数据库的某些权限:
mysql>grant select,delete,update,create,drop on *.* to 'test'@'%' identified by "123456";
--test用户对所有数据库都有select,delete,update,create,drop 权限。
--@"%" 表示对所有非本地主机授权,不包括localhost。
--对localhost授权:加上一句grant all privileges on testDB.* to 'test'@'localhost' identified by '123456';即可。
相关文章推荐
- mysqli 连接数据库实例
- mysql-5.6.21源代码安装步骤
- MYSQL 创建用户
- MySQL技术之旅-慢查询日志可视化平台的使用(Anemometer)
- mac os 10.10.4上安装mysql5.6.26
- JDBC连接MySQL
- MySQL的锁机制
- Mysql master/slave replication
- MySQL 外连接、内连接,连接查询、多表查询、子查询、视图
- mysql查询
- perl 卸载mysql数据库
- mySQL大量数据中去重复查询
- MySQL几个计算时间的函数汇总
- mysql忘记密码怎么办
- MySql避免重复插入记录
- MySQL技术之旅-慢查询作用、解析工具
- 找不到mysql.sock的出现原因及解决方案和mysql 默认mysql.sock位置默认问题探讨
- mysql 设置 utf-8
- Mysql 忘记密码
- Mysql操作常用命令