数据库的账号信息
mysql 数据库的账号信息都存储在mysql库中里
在mysql库中使用select user,host,password from user;
就可以查找到该数据库的账号密码等相关信息
用户管理
删除用户
delete from sql.user where user='用户名';
用户授权 grant
grant 授权内容 on 库名.表名 to '用户名'@"登录主机ip 地址" identified by "密码";
查看权限
show grants for '用户名'@'登录主机ip'\G
撤销权限 revoke
revoke 撤权内容 on 库名.表名 from '用户名'@'登录主机ip 地址';
删除用户
drop user "用户名"@'登录主机ip 地址';
案例
1新建一个用户,并且授权
grant all on xl_bbs.user to 'xl'@"%" identified by "123456";
2查看用户权限 show grants for "xl"@"%";
3撤销用权限 revoke all on *.* from "xl"@"%";
4删除用户 drop user "xl"@"%";
5允许root 远程登录数据库 GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY '123456' WITH GRANT OPTION;