4、mysql数据库的权限管理

版权声明:chaizepeng https://blog.csdn.net/chaizepeng/article/details/87883025

权限管理指的是对试图连接和操作数据库服务器的用户进行访问控制

关于权限管理的一些sql实例如下:

-- 首先通过cmd窗口连接mysql服务器
mysql -u root -p *******

-- mysql数据库下有一个user表,里边存储的是user的信息
select user from user;

-- 添加一个用户
create user 用户名@主机名 identified by 密码
create user chaizepeng@localhost identified by '123456';

-- 给新创建的用户chaizepeng一些权限
grant 权限名 on 数据库名.表明 to 指定用户
grant select on fqx_webapp.* to chaizepeng@localhost;
注意:数据库名和表名都可以使用通配符*进行表型

-- 查看用户有那些权限
show grants for chaizepeng@localhost; 

-- 去除用户的一些权限
revoke select on fqx_webapp.* from chaizepeng@localhost;

-- 修改用户的密码
set password for 用户名=PASSWORD('新密码');
set password for chaizepeng@localhost=PASSWORD('654321');
-- 或者修改user表中的密码,注意一定要写上条件
use mysql; -- 切换到mysql数据库
udpate user set password = password('654321') where user = 'chaizepeng';
flush privileges;

猜你喜欢

转载自blog.csdn.net/chaizepeng/article/details/87883025