mysql 用户权限管理

网上很多人的授权都有问题的,特别是因为对于IP那个地方没有用引号.....大部分人COPY的吧..特留此笔记酷

用root本地账户登录mysql,增加新用户

insert into mysql.user(Host,User,Password) values('%','admin','abc123');--增加admin的账户(密码abc123),此账户可以从任何IP访问,但不包括localhost(version:5.5.9),version:5.7.1 % 也包括localhost的访问
insert into mysql.user(Host,User,Password) values('localhost','admin','abc123');--增加admin的账户(密码abc123),此账户只可以从localhost访问

授权

grant all privileges on *.* to 'admin'@'%' identified by 'abc123';--授权,grant 权限 on 数据库.表 to '账户'@'IP' identified by 'abc123'
grant all privileges on *.* to 'admin'@'localhost' identified by 'abc123';--注意标点符号

  

 刷新权限

 FLUSH PRIVILEGES;--刷新授权

猜你喜欢

转载自zhushidan100.iteye.com/blog/1883030