1.查看所有用戶
SELECT DISTINCT CONCAT('User: ''',user,'''@''',host,''';') AS query FROM mysql.user;
2.查看某一用戶具體權(quán)限
show grants for 'root'@'localhost';
#格式 'xxxx'@'xx.xx.xx.xx'
3.創(chuàng)建用戶
CREATE USER 'username'@'host' IDENTIFIED BY 'password';
#'username'@'host'中的host可以是%代表所有ip都可以登錄
4.授予某個(gè)用戶權(quán)限
GRANT ALL PRIVILEGES ON *.* TO 'xxxx'@'xx.xx.xx.xx' IDENTIFIED BY 'newpwd' WITH GRANT OPTION;
# *.* 代表所有數(shù)據(jù)庫的所有表
# 'xxxx'@'xx.xx.xx.xx' 代表某個(gè)用戶在什么ip范圍下有權(quán)限
# IDENTIFIED BY 指定密碼
# WITH GRANT OPTION 有繼續(xù)授予其他用戶的權(quán)限