mysql root用户远程访问权限_MySQL 用户与权限

点击上方☝ SpringForAll社区  轻松关注! 及时获取有趣有料的技术文章
bd3e60919e51c60dd2485a0e80541bb5.png

创建新用户

创建用户,用户名为 testuser,密码为 123456,仅可本地连接

1grant all privileges on *.* to testuser@localhost identified by "123456";

允许指定 IP 远程访问

1grant all privileges on *.* to testuser@"192.168.1.100" identified by "123456";

允许指定 IP 段远程访问

1grant all privileges on *.* to testuser@"192.168.1.%" identified by "123456";

允许所有 IP 远程访问

1grant all privileges on *.* to testuser@"%" identified by "123456";

提醒:分配权限后,需执行 flush privileges;,使其生效,下同。


修改用户访问数据库权限

允许用户访问所有数据库

1grant all privileges on *.* to testuser@localhost identified by "123456";

允许用户访问指定数据库 test_db

1 grant all privileges on test_db.* to testuser@localhost identified by "123456";

允许用户访问指定数据库 test_db 的指定表 user

1grant all privileges on test_db.user to testuser@localhost identified by "123456" ; 

修改用户操作权限

允许用户所有操作权限

1grant all privileges on *.* to testuser@localhost identified by "123456" WITH GRANT OPTION ;

允许用户查询权限

1grant select on *.* to testuser@localhost identified by "123456" ;

允许用户增删改查权限

1 grant select,insert,update,delete on *.* to testuser@localhost identified by "123456"  ;

常用设置

查询所有用户

1use mysql;
2select User,Host from user;

关闭 root 用户远程访问权限

1use mysql;
2delete from user where user="root" and host="%" ;

8d4ca10b6f483fb3b0a5a16b23ff5852.gif

● MongoDB - 用户与权限

● SpringForAll社区,2019年文章精选10篇

● 高并发系统中的限流应该如何做?

● 经验:一个秒杀系统的设计思考!

● 如何设计缓存系统:缓存穿透,缓存击穿,缓存雪崩解决方案分析

● 微服务 2.0 技术栈选型手册

● 你需要的大厂在用的分库分表方案,都在这里!

● 拜托,面试别再问我数据库的分库分表!

● Spring Boot实战:逐行释义HelloWorld

● Spring Boot的自动配置、Command-line Runner

● SpringRetry重试机制

● 高性能的零拷贝技术原理你真懂吗?

● Java 文件处理 Paths & Files

● Spring Boot 应用 - 静态视频资源实时播放新姿势

● 面试 Spring Boot 再也不怕了,答案都在这里了!

● Spring Boot 默认的指标数据从哪来的?

● 技术人面对裁员的终极解决方案-反脆弱

50c43377d235d084769364ac590f385d.png

d946497980cfbef81891671e89ac1990.gif

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值