• 查看所有用户
select distinct concat(user, '@', host,';') as userList from mysql.user;

select  #查找

distinct  #去重复

concat  #拼接字符串

as  #换个别名

 

  • 查看当前登陆的是哪个用户
select user();

 

  • 添加一个新用户
create user 'username'@'host' identified by 'passwd';

identified by #由...鉴别,这里是给这个用户添加个密码

 

  • 给用户修改密码
set password for 'username'@'host' = password("123456");

 

  • 删除用户
drop user 'username'@'host';

 

  • 查看具体某个用户的权限
show grants for 'username'@'host';

 

  • 给用户username的数据库databasename中的表tablename授select和insert权。
grant select, insert on databasename.tablename to 'username'@'host'

 

  • 给username用户所有表授所有权
grant all on *.* to 'username'@'host';

 

  • 撤销权限
revoke select on databasename.tablename from 'username'@'host';

 

相关文章:

  • 2021-06-17
  • 2021-10-11
  • 2022-01-21
  • 2021-09-10
  • 2021-06-22
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-01-07
  • 2022-12-23
  • 2021-07-05
  • 2021-10-31
  • 2021-11-26
  • 2021-12-03
  • 2022-01-07
相关资源
相似解决方案