1 创建用户:
create user 'username'@'%' identified by 'password';
username: 用户名
password: 密码
user表中host列的值的意义
% 匹配所有主机
localhost localhost不会被解析成IP地址,直接通过UNIXsocket连接
127.0.0.1 会通过TCP/IP协议连接,并且只能在本机访问;
::1 ::1就是兼容支持ipv6的,表示同ipv4的127.0.0.1
2 配置权限
对数据库授所有权限:
全部数据库
grant all privileges on *.* to 'openfalcon'@'localhost' with grant option;
某个数据库
grant all privileges on userdb.* to user; --- user 为用户名
对用户给予针对指定数据库进行增删改查的权限
grant select,insert,update,delete,create on databasename.* to username;
3 刷新授权
flush privileges;
4 查看授权:
show grants for [username];
5 删除权限
通过revoke命令可以移除用户的相关权限
revoke drop on databasename.* from username;
注