一.添加用户
1.创建只允许指定ip连接
create user '新用户名'@'localhost' identified by '密码';2.创建允许所有ip连接(用通配符%表示)
create user '新用户名'@'%' identified by '密码';二.为新用户授权
1.基本格式如下
grant all privileges on 数据库名.表名 to '新用户名'@'指定ip' identified by '新用户密码' ;例如:
(1)允许访问所有数据库下的所有表
grant all privileges on *.* to '新用户名'@'指定ip' identified by '新用户密码' ;(2)指定数据库下的指定表
grant all privileges on test.test to '新用户名'@'指定ip' identified by '新用户密码' ;三.设置用户操作权限
1.设置用户拥有所有权限也就是管理员
grant all on *.* to '用户名'@'%';2.拥有查询权限
grant select on *.* to '新用户名'@'指定ip' identified by '新用户密码' WITH GRANT OPTION;3.其它操作权限说明,select查询 insert插入 delete删除 update修改
(1)设置用户拥有查询插入的权限
grant select,insert on *.* to '新用户名'@'指定ip' identified by '新用户密码' WITH GRANT OPTION;(2)取消用户查询的查询权限
REVOKE select ON what FROM '新用户名';四.删除用户
DROP USER username@localhost;五.修改后刷新权限
FLUSH PRIVILEGES;版权声明:本文为m0_59799878原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。