日期:2014-05-16  浏览次数:20746 次

Mysql用户创建、授权以及删除

?

1、用户创建

CREATE DATABASE db_test;
CREATE USER user IDENTIFIED BY 'passwd';

?? ?注:user为用户名, passwd为密码

?? ?这样创建的用户是不限制用户访问的IP,也就是'%',上面等价于:

CREATE USER utel@'%' IDENTIFIED BY 'utel789';

?? ?如果只能本地访问,可以

CREATE USER utel@'localhost' IDENTIFIED BY 'utel789';

2、授权

GRANT ALL PRIVILEGES on db_test.* TO user@'%';
?? ?授权user可以操作db_test库的所有权限


3、删除用户

?? ?1)删除授权

revoke privileges (columns) on what from user;
??? ?2)删除用户

delete from mysql.user where user='user' and host='%';
?4、查看

select host, user from mysql.user;
?

5、修改密码

set password for user@'%'=Password('passwd_new');
?

?