查看用户:
SELECT * FROM mysql.user
新增用户:
CREATE user 'li1'@'localhost' IDENTIFIED BY 'Li123456!';
删除用户:
drop user 'li1'@'localhost';
修改用户名:
rename user 'li1'@'localhost' to 'li2'@'localhost';
修改密码:
set password for 'li1'@'localhost' = PASSWORD('Li123456!!');
权限:
# 添加所有权限
grant all privileges on `test`.* to 'li1'@'localhost';
# 查询权限
grant select on `test`.* to 'li1'@'localhost';
# 查询,插入,更新权限
grant select,insert,update on `test`.* to 'li1'@'localhost';
# 删除权限
revoke insert,update on test.* from 'li1'@'localhost';
# 刷新权限
flush privileges;
# 查看某用户权限
show grants for 'li1'@'localhost';