MySQL帐户管理
时间:2010-05-07 来源:linuxangie
一.添加用户
1.Insert into user ( user,host,password ) values ('linux','%',password('linuxangie '));
此语句MySQL 5.0以上版本不支持。
2.Grant all on *.* to 'linux'@'%'identified by 'linuxangie';
添加用户linux,密码为linuxangie,拥有所有权限。
3.Grant usage on *.* to 'angie'@'%' identified by 'linuxangie';
Grant select, insert, update, delete, create, drop, reload, shutdown, process, file, grant, references, index, alter, show databases, super, create temporary tables, lock tables, execute, replication slave, replication client on *.* to 'angie'@'%';
Grant usage on *.* to 'angie'@'%' with grant option;
注:第2语句相当于第3语句。
二.删除root@localhost帐户和空用户名的帐户
1. Delete from user where user='';
2. Delete from user where user='root'and host='locahost';
3. 删除''和'linux','angie'的三个帐户
Delete from user where user=' 'or user='linuxwei' or user='angie';
三.修改linux用户名和密码
Update user set user='linuxangie' where user='linux';
Update user set password=password('linuxangie ') where user='linuxangie';
Select * from user;
四.权限刷新
Flush privileges;