【1】查看mysql数据库中的所有用户

1
SELECT DISTINCT CONCAT('User: ''',user,'''@''',host,''';') AS query FROM mysql.user;

【2】查看某个用户的权限

1
2
3
show grants for 'nextcloud'@'%'; 
-- or
select * from mysql.user where user='root' \G;

【3】查看当前用户

1
select user();

【4】修改用户密码

1
2
3
use mysql;
UPDATE user SET password=PASSWORD('新密码') WHERE user='用户';
flush privileges;

【5】修改用户权限及密码

1
2
-- grant 权限 on 库名.表名 to '用户名'@’网段‘  identified by  "该用户的密码";
grant all privileges on nextcloud.* to 'nextcloud'@'%' identified by 'du..olctx..entest.1';

【6】删除用户

1
drop user 'nextcloud'@'%';

转载自:

https://blog.csdn.net/GX_1_11_real/article/details/95052475