2 Star 1 Fork 0

enilu / book

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
mysql权限管理.md 793 Bytes
一键复制 编辑 原始数据 按行查看 历史
zhangtao 提交于 2020-12-08 18:51 . Add init

mysql权限管理

下面语句授权用户统一从本地(localhost)登录,如果需要用户可以从远程登录将Host更改为“%”即可。

  • 创建用户
insert into mysql.user(Host,User,Password) values("localhost","enilu",password("1234"));
flush privileges;
  • 为用户授权
create database testdb;
grant all privileges on testdb.* to enilu@localhost identified by '1234';
flush privileges;
  • 为用户授权(查询和修改)
grant select,update on testdb.* to enilu@localhost identified by '1234';
flush privileges;
  • 删除用户
DELETE FROM user WHERE User="enilu" and Host="localhost";
flush privileges;
  • 修改用户的密码
update mysql.user set password=password('新密码') where User="enilu" and Host="localhost";
1
https://gitee.com/enilu/book.git
git@gitee.com:enilu/book.git
enilu
book
book
master

搜索帮助