mysql创建用户分配权限
version:6.7.6+
1、创建用户:
create user username identified by 'myPassword';
或
create user 'test'@'127.0.0.1' ;
2、修改密码:
alter user test identified by 'test';
3、设置权限
grant all privileges on mydb.* to 'test'@'%' identified by 'test';
给 mydb 库 * (所有对象) all (所有权限),设置密码‘test’,‘%’ 匹配所有ip
privileges 代表权限select,insert,update,delete,create,drop,index,alter,grant,references,reload,shutdown,process,file等14个权限
例子:mysql>grant select,insert,update,delete,create,drop on test.hr to test@127.0.0.1 identified by '123';
设置 增、删、改、查、删表权限给 test@127.0.0.1
4、保存,退出。
flush privileges; \q;