管理系统中的对象权限时使用
①创建用户
create user ‘username‘@‘localhost‘ identified by ‘password‘;
create user ‘my_user‘@‘localhost‘ identified by ‘cqq‘;
本地用户:‘localhost’, 任意主机:‘%’,远程:‘ip‘
②授权
grant all on db.* to ‘my_user‘ @‘localhost‘;//将对db数据库的所有操作权限授予my_user用户,my_user用户的主机是localhost
grant all on *.* to [email protected]‘localhost‘;//将root用户下对所有数据库的所有操作权限全部授予my_user 用户
select* from mysql.user;//查看所有的用户信息(user,host等)
③修改密码
set password for [email protected]‘localhost‘=‘12345‘
④回收权限
revoke all on db.* from ‘my_user‘ @‘localhost‘;
⑤删除用户
drop user ‘my_user‘ @‘localhost‘;