Home > Database > Mysql Tutorial > mysql用户权限管理_MySQL

mysql用户权限管理_MySQL

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-06-01 13:34:04
Original
840 people have browsed it

bitsCN.com

mysql用户权限管理

 

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

 

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

 

Sql代码  

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访问  

 

授权

Sql代码  

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';--注意标点符号  

 

 刷新权限

Sql代码  

FLUSH PRIVILEGES;--刷新授权

 

bitsCN.com
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Issues
MySQL stops process
From 1970-01-01 08:00:00
0
0
0
Error when installing mysql on linux
From 1970-01-01 08:00:00
0
0
0
phpstudy cannot start mysql?
From 1970-01-01 08:00:00
0
0
0
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template