MySQL 添加用户并授予只能查询权限

1.创建用户

create user 'userName'@'%' identified by '123456';

用户名为userName,密码是123456的用户(userName,123456可指定)

2.授予权限

grant select on mysql.* to 'userName'@'%';

授予用户名为userName,数据库为mysql的查询权限。(mysql是数据库名称,可指定)

3.刷新权限缓存

flush privileges;

posted @ 2022-09-20 16:35  胖胖123  阅读(166)  评论(0编辑  收藏  举报