python用户的创建和授权

针对新用户的操作

创建用户
mysqladmin -u用户名 -p旧密码 password 新密码

mysql> create user '用户名'@'地址' identified by '密码';

删除用户
drop user '用户名'@'地址';

修改用户
rename user '用户名'@'地址' to '新用户名'@'地址';

修改密码:
mysql> set password for 用户名@地址 = password('新密码');

对当前用户授权

# 查看指定用户权限
show grants for '用户名'@'地址'

# 给用户授权: 对文件夹,对文件,对文件某一字段的权限
mysql> grant 权限 on 库名.表名 to '用户名'@'地址';

# 创建用户名密码并授权
mysql> grant all on *.* to '用户名'@'%' identified by '密码'
# all表示所有权限
# select 表示查询权限
# insert 表示插入数据的权限
# update 表示更新数据的权限
# delete 表示删除数据的权限
# all可以代表除了grant之外的所有权限

#删除权限
revoke 权限 on db1.* from '用户名'@'地址';

# 查看当前用户
mysql> select user()

# 更新当前用户的密码
mysql> update user set password=password("123") where user="root";

grant select (id,name),update (age) on db1.t3 to '用户'@'地址' identified by '123'; 

#可以在tables_priv和columns_priv中看到相应的权限
select * from 表名 where user='用户名'\G

 

posted @ 2019-03-07 17:34  LinuxCBB  阅读(892)  评论(0)    收藏  举报