查看现有的用户
select host,user,authentication_string from mysql.user;
创建用户
create user '用户名'@'host' identified by "密码";
host="localhost"为本地登录用户
host="ip"为ip地址登录
host="%",为外网ip登录
删除用户
drop user 'username'@'host';
权限设置
//授予用户通过外网IP对于该数据库的全部权限
grant all privileges on `test`.* to 'test'@'%' ;
/*授予用户在本地服务器对该数据库的全部权限*/
grant all privileges on `test`.* to 'test'@'localhost';
grant select on test.* to 'user1'@'localhost'; /*给予查询权限*/
grant insert on test.* to 'user1'@'localhost'; /*添加插入权限*/
grant delete on test.* to 'user1'@'localhost'; /*添加删除权限*/
grant update on test.* to 'user1'@'localhost'; /*添加权限*/
flush privileges; /*刷新权限*/
查看权限
show grants; //全部
show grants for 'jack'@'%'; //指定用户
删除权限
revoke privileges on databasename.tablename from 'username'@'host';
revoke delete on test.* from 'jack'@'localhost';
https://www.cnblogs.com/wuxunyan/p/9095016.html
grant 权限 on 数据库对象 to 用户
https://www.cnblogs.com/yunfeioliver/p/7887676.html