mysql添加用户和分配权限
查询所有用户(mysql库下)
select * from user;
创建一个新用户
CREATE USER 'zhong'@'localhost' IDENTIFIED BY '123456'; //只允许本地登录 CREATE USER 'zhong'@'%' IDENTIFIED BY '123456'; //允许所有ip登录
指定部分权限(数据库zhong_base的所有表,分配Select,Update,Insert,Delete权限)
grant Select,Update,Insert,Delete on zhong_base.* to 'zhong'@'%' identified by '123456';
flush privileges;
指定所有权限
grant all privileges on zhong_base.* to 'zhong'@'%' identified by '123456';
flush privileges;
取消用户权限(取消用户的Update,Insert,Delete权限)
revoke Update,Insert,Delete on zhong.* from 'zhong'@'%';
查看该用户的权限
show grants for 'zhong'@'%'
删除用户
delete from user where user='zhong' and host='%'; flush privileges;
删除用户及权限
drop user 'zhong'@'%';
修改密码
set password for 'zhong'@'localhost'=password('123456');