mysql用户权限操作

1.权限管理

select host, user ,authentication_stringfrommysql.user;

2.添加用户

flushprivileges;

createuser ‘wang’@’localhost’identified by ‘123’;

insert intomysql.user(host,user,ssl_cipher,x509_issuer,x509_subject)

values(‘localhost’,‘xiao’, ‘ ’, ’ ‘, ’ ’);

3.查看用户

select host, user from mysql.user;

4.修改用户账号

rename user‘xiao’@’localhost’ to ‘da’ @’localhsot’;

5.修改用户密码口令

要退到mysql/bin目录下:

mysqladmin–u da –ppassword

输入旧密码

输入新密码

确认新密码

set passwordfor ‘da’@’localhost’=password(‘123’);

update mysql.userset authentication=password(‘123’)where user=’da’;

11.删除用户

drop userda@lcoalhost;

delete frommysql.usr whereuser=’ma’;

12.权限授予

grantselect(sno,sname) on studentinfo.student to 'ma'@'localhost';

grant all onstudentinfo.* to 'ma'@'localhost';

13.转移权限

grantselect,update on studentinfo.student to 'zhou'@'localhost' identified by '123'with grant option;

14.限制权限

grant delete onstudentinfo.* to 'ma'@'localhost'with max_queries_per_hour 1;

15.权限的撤销

revoke select onstudentinfo.student from 'zhou'@'

你可能感兴趣的:(mysql用户权限操作)