Mysql数据库常用操作
作者:互联网
一、权限管理
1.创建库test
create database test;
2.创建用户user01对库test有所有权限
grant all on test.* to 'user01'@'%' identified by 'password';
3.创建用户并授与root相同授权权限。[grant 权限 on 数据库对象 to 用户]
grant all on *.* to 'user01'@'%' identified by '123456' with grant option;flush privileges;
4.只创建一个用户:
CREATE USER 'test'@'%' IDENTIFIED BY '1234';
5.添加用户并授权:
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY '12' WITH GRANT OPTION;
6.叠加权限,给user01用户所有库所有表增删改查的权限,只是select就是只有查询权限
grant select,insert,update,delete on *.* to 'user01'@'%' identified by 'password';
7.查看user01的权限
show grants for user01@%;
8.修改数据库密码:
SET PASSWORD FOR 'root'@'localhost' = PASSWORD('123');
update mysql.user set authentication_string=password(“123”) where User=”test” and Host=”localhost”;
9.撤销权限
首先查看该用户的权限,然后复制想要撤销的权限,将grant 改成revoke,将to 改为from 。
show grants for user01@%;
标签:常用,password,grant,数据库,用户,Mysql,test,权限,user01 来源: https://blog.csdn.net/zhutongcloud/article/details/91048346