1.查看所有用户
SELECT DISTINCT CONCAT('User: ''',user,'''@''',host,''';') AS query FROM mysql.user;
2.查看某一用户具体权限
show grants for 'root'@'localhost';
#格式 'xxxx'@'xx.xx.xx.xx'
3.创建用户
CREATE USER 'username'@'host' IDENTIFIED BY 'password';
#'username'@'host'中的host可以是%代表所有ip都可以登录
4.授予某个用户权限
GRANT ALL PRIVILEGES ON *.* TO 'xxxx'@'xx.xx.xx.xx' IDENTIFIED BY 'newpwd' WITH GRANT OPTION;
# *.* 代表所有数据库的所有表
# 'xxxx'@'xx.xx.xx.xx' 代表某个用户在什么ip范围下有权限
# IDENTIFIED BY 指定密码
# WITH GRANT OPTION 有继续授予其他用户的权限
网友评论