![bd3e60919e51c60dd2485a0e80541bb5.png](https://img-blog.csdnimg.cn/img_convert/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="%" ;
● MongoDB - 用户与权限
● SpringForAll社区,2019年文章精选10篇
● 高并发系统中的限流应该如何做?
● 经验:一个秒杀系统的设计思考!
● 如何设计缓存系统:缓存穿透,缓存击穿,缓存雪崩解决方案分析
● 微服务 2.0 技术栈选型手册
● 你需要的大厂在用的分库分表方案,都在这里!
● 拜托,面试别再问我数据库的分库分表!
● Spring Boot实战:逐行释义HelloWorld
● Spring Boot的自动配置、Command-line Runner
● SpringRetry重试机制
● 高性能的零拷贝技术原理你真懂吗?
● Java 文件处理 Paths & Files
● Spring Boot 应用 - 静态视频资源实时播放新姿势
● 面试 Spring Boot 再也不怕了,答案都在这里了!
● Spring Boot 默认的指标数据从哪来的?
● 技术人面对裁员的终极解决方案-反脆弱