我使用的是mysql8.0
创建用户 地址为 % 则任何ip都可以访问,为localhost则只能本地访问
create user '用户名'@'地址' identified by '8位数密码';
给用户select的权限 或者 所有权限 database 为数据库名 后面*代表所有表
grant select on database.* to 'user'@'%';
grant all privileges on database.* to 'user'@'%';
刷新权限
flush privileges;
查看用户权限
show grants for user_name;
show grants for user_name@localhost;
删除用户
drop user user_name@'%';