135-1821-9792

mysql怎么给用户授权 mysql建用户授权

如何在MySQL中创建用户以及授权

mysql中可以给你一个用户授予如select,insert,update,delete等其中的一个或者多个权限,主要使用grant命令

我们提供的服务有:网站制作、网站设计、微信公众号开发、网站优化、网站认证、监利ssl等。为千余家企事业单位解决了网站和推广的问题。提供周到的售前咨询和贴心的售后服务,是有科学管理、有技术的监利网站制作公司

如何设置mysql用户的权限

1、创建新用户

通过root用户登录之后创建

grant all privileges on *.* to testuser@localhost identified by "123456" ;//创建新用户,用户名为testuser,密码为123456 ;

grant all privileges on *.* to testuser@localhost identified by "123456" ;//设置用户testuser,可以在本地访问mysql

grant all privileges on *.* to testuser@"%" identified by "123456" ; //设置用户testuser,可以在远程访问mysql

flush privileges ;//mysql 新设置用户或更改密码后需用flush privileges刷新MySQL的系统权限相关表,否则会出现拒绝访问,还有一种方法,就是重新启动mysql服务器,来使新设置生效

2、设置用户访问数据库权限

grant all privileges on test_db.* to testuser@localhost identified by "123456" ;//设置用户testuser,只能访问数据库test_db,其他数据库均不能访问 ;

grant all privileges on *.* to testuser@localhost identified by "123456" ;//设置用户testuser,可以访问mysql上的所有数据库 ;

grant all privileges on test_db.user_infor to testuser@localhost identified by "123456" ;//设置用户testuser,只能访问数据库test_db的表user_infor,数据库中的其他表均不能访问 ;

3、设置用户操作权限

grant all privileges on *.* to testuser@localhost identified by "123456" WITH GRANT OPTION ;//设置用户testuser,拥有所有的操作权限,也就是管理员 ;

grant select on *.* to testuser@localhost identified by "123456" WITH GRANT OPTION ;//设置用户testuser,只拥有【查询】操作权限 ;

grant select,insert on *.* to testuser@localhost identified by "123456" ;//设置用户testuser,只拥有【查询\插入】操作权限 ;

grant select,insert,update,delete on *.* to testuser@localhost identified by "123456" ;//设置用户testuser,只拥有【查询\插入】操作权限 ;

REVOKE select,insert ON what FROM testuser//取消用户testuser的【查询\插入】操作权限 ;

mysql怎样添加用户授权

方法/步骤

我们以管理员的身份先登录到数据库服务器上,我想登录到数据库服务器

我先新建一个数据库用户,

可以复制权限,这个用户可以访问那几个数据库等,是否能删除,修改,添加,等等的一些权限

每个小时的链接数,每个小时的查询,最大的并发数,等等

我是选择这个用户只能控制一个数据库的使用,其他的数据库不让他看见

我们登录一下这个用户测试一下,这个时候你会发现是只有一个自己的数据库其他的数据库就看不见了,具体的还有很多的权限控制,这里就不一一介绍啦,


网页标题:mysql怎么给用户授权 mysql建用户授权
网站URL:http://kswsj.com/article/doedohg.html

其他资讯



Copyright © 2009-2022 www.kswsj.com 成都快上网科技有限公司 版权所有 蜀ICP备19037934号