1、查询MySql用户
select user,host from mysql.user;
2、创建用户
create user 'test'@'localhost' identified by '1122';
指定localhost,则该用户只能在本地登录,不能在其他机器上登录。如果要远程登录,则将’localhost’ 改为’%'
3、删除用户
drop user test@localhost;
4、给新用户分配权限
grant select,insert,update,delete on 数据库名称.* to test@localhost identified by '1122';
或
grant all privileges on 数据库名称.* to test@localhost identified by '1122';
grant all privileges on 数据库名称.* to test@'%' identified by '1122';
5、刷新权限 立即启用
FLUSH PRIVILEGES;