SQL之DCL(管理用户.权限)
管理用户:
1.添加用户
2.删除用户
3.修改密码
(修改root密码、修改普通用户密码)
4.查询用户
1.添加用户
CREATE USER '用户名'@'主机名' IDENTIFIED BY '密码';
-- localhost:当前主机 、% 任意主机
举例:
CREATE USER 'xiaohong'@'localhost' IDENTIFIED BY '123';
CREATE USER 'xiaoli'@'%' IDENTIFIED BY '123';
2.删除用户
drop user '用户名'@'主机名';
举例:
DROP USER 'xiaoli'@'%';
3.修改密码
1.修改普通用户密码:
5.0:
update user set password = password('新密码') where user = '用户名';
set password for '用户名'@'主机名' = password('新密码');
UPDATE USER SET PASSWORD = PASSWORD("456") WHERE USER = 'zhangsan';
set password for 'zhangsan'@'localhost' = password('456');
8.0:
ALTER