mysql 新增 删除用户和权限分配
2013-01-13 20:42
344 查看
http://lionbule.iteye.com/blog/1114072
1. 新增用户
Sql代码
mysql>insert into mysql.user(Host,User,Password)
values("localhost","lionbule",password("hello1234"));
mysql>flush privileges;
2. 修改用户密码
Sql代码
mysql>update mysql.user
set password=password('new password')
where User="lionbule"
and Host="localhost";
mysql>flush privileges;
3. 删除用户
Sql代码
mysql>DELETE FROM
user
WHERE User="lionbule"
and Host="localhost";
mysql>flush privileges;
4. 权限分配
4.1. grant用法
grant
权限 on 数据库.*
to 用户名@'登录主机'
identified by '密码'
Doc代码
权限:
常用总结, ALL/ALTER/CREATE/DROP/SELECT/UPDATE/DELETE
数据库:
*.* 表示所有库的所有表
test.* 表示test库的所有表
test.test_table 表示test库的test_table表
用户名:
mysql账户名
登陆主机:
允许登陆mysql server的客户端ip
'%'表示所有ip
'localhost' 表示本机
'192.168.10.2' 特定IP
密码:
账户对应的登陆密码
4.2 例子
Sql代码
mysql>grant all
on test.* to lionbule@'%' identified
by 'hello1234';
mysql>flush privileges;
新增密码为‘hello234’的用户lionbule对test库拥有所有操作权限,并不限制lionbule用户的登陆IP。
4.3 注意事项
grant 会覆盖用户的部分信息,跟insert 、update执行功能一样.
参考:
http://dev.mysql.com/doc/refman/5.6/en/grant.html
http://www.cnblogs.com/hcbin/archive/2010/04/23/1718379.html
1. 新增用户
Sql代码
mysql>insert into mysql.user(Host,User,Password)
values("localhost","lionbule",password("hello1234"));
mysql>flush privileges;
mysql>insert into mysql.user(Host,User,Password) values("localhost","lionbule",password("hello1234")); mysql>flush privileges;
2. 修改用户密码
Sql代码
mysql>update mysql.user
set password=password('new password')
where User="lionbule"
and Host="localhost";
mysql>flush privileges;
mysql>update mysql.user set password=password('new password') where User="lionbule" and Host="localhost"; mysql>flush privileges;
3. 删除用户
Sql代码
mysql>DELETE FROM
user
WHERE User="lionbule"
and Host="localhost";
mysql>flush privileges;
mysql>DELETE FROM user WHERE User="lionbule" and Host="localhost"; mysql>flush privileges;
4. 权限分配
4.1. grant用法
grant
权限 on 数据库.*
to 用户名@'登录主机'
identified by '密码'
Doc代码
权限:
常用总结, ALL/ALTER/CREATE/DROP/SELECT/UPDATE/DELETE
数据库:
*.* 表示所有库的所有表
test.* 表示test库的所有表
test.test_table 表示test库的test_table表
用户名:
mysql账户名
登陆主机:
允许登陆mysql server的客户端ip
'%'表示所有ip
'localhost' 表示本机
'192.168.10.2' 特定IP
密码:
账户对应的登陆密码
权限: 常用总结, ALL/ALTER/CREATE/DROP/SELECT/UPDATE/DELETE 数据库: *.* 表示所有库的所有表 test.* 表示test库的所有表 test.test_table 表示test库的test_table表 用户名: mysql账户名 登陆主机: 允许登陆mysql server的客户端ip '%'表示所有ip 'localhost' 表示本机 '192.168.10.2' 特定IP 密码: 账户对应的登陆密码
4.2 例子
Sql代码
mysql>grant all
on test.* to lionbule@'%' identified
by 'hello1234';
mysql>flush privileges;
mysql>grant all on test.* to lionbule@'%' identified by 'hello1234'; mysql>flush privileges;
新增密码为‘hello234’的用户lionbule对test库拥有所有操作权限,并不限制lionbule用户的登陆IP。
4.3 注意事项
grant 会覆盖用户的部分信息,跟insert 、update执行功能一样.
参考:
http://dev.mysql.com/doc/refman/5.6/en/grant.html
http://www.cnblogs.com/hcbin/archive/2010/04/23/1718379.html
相关文章推荐
- mysql 新增 删除用户和权限分配
- mysql 新增 删除用户和权限分配
- mysql 新增、删除用户和权限分配
- mysql 新增 删除用户和权限分配
- mysql 新增 删除用户和权限分配
- MySQL 新增、删除用户和权限分配-直接修改mysql.user表
- mysql 新增、删除用户和权限分配
- Mysql 添加用户、删除用户与 数据库权限分配
- mysql 简单创建删除用户并分配数据库访问权限
- MYSQL添加新用户 MYSQL为用户创建数据库 MYSQL为新用户分配权限 无法使用新增的用户登陆mysql
- MySQL 新增用户 权限分配 远程登录
- mysql创建用户、删除用户、创建root用户和修改用户密码,grant分配权限,查询测试,以及库中授权表解析
- MySQL创建普通用户、分配权限、删除用户、修改用户密码
- 如何给mysql用户分配权限+增、删、改、查mysql用户
- mysql用户添加删除编辑权限管理等简述
- MySQL 用户权限分配 Grant 语法详解
- mysql 创建用户并分配权限
- MySQL用户分配权限
- mysql用户密码修改,用户添加、删除、设置权限及源文件恢复数据库
- 向mysql添加新用户并分配权限