1、创建用户
CREATE USER 'test'@'localhost' IDENTIFIED BY 'test123;
2、为用户赋权
grant all privileges on *.* to test@localhost identified by 'test123';
flush privileges;//刷新系统权限表
格式:grant 权限 on 数据库.* to 用户名@登录主机 identified by "密码";
3、如果想指定部分权限给一用户,可以这样来写:
mysql>grant select,update on testDB.* to test@localhost identified by '1234';
mysql>flush privileges; //刷新系统权限表
4、开放远程权限
GRANT ALL PRIVILEGES ON *.* TO 'rw_wangjie_user'@'%' IDENTIFIED BY 'd[AG9kjnynp4zj' WITH GRANT OPTION;
flush privileges;