----------------------------------------------------------新建用户-------------------------------------------------------
5.7版本
create user ‘test’@‘%’ identified by ‘123456’;
修改密码
alter user ‘test’@‘%’ identified by ‘123456’;
8.0版本
create user ‘test’@‘%’ identified with mysql_native_password by ‘123456’;
修改密码
alter user ‘test’@‘%’ identified with mysql_native_password by ‘123456’;
----------------------------------------------------------查看权限----------------------------------------------------------
show grants for ‘root’@‘localhost’;
----------------------------------------------------------授权分配----------------------------------------------------------
授予所有权限
grant all privileges on . to ‘test’@‘%’;
flush privileges;
授予特定权限
grant select on testdb
.* to ‘test’@‘%’;
grant select,insert,delete,update on testdb
.* to ‘test’@‘%’;
flush privileges;
PROCESS 权限
GRANT PROCESS, SELECT ON . to ‘test’@‘%’;
flush privileges;
slave权限
grant select on testdb
.* to ‘slave’@‘192.168.2.%’;
grant REPLICATION CLIENT ON . to ‘slave’@‘192.168.2.%’;
GRANT REPLICATION SLAVE ON . TO ‘slave’@‘192.168.2.%’;
flush privileges;
授予连接权限并设定最大连接数
GRANT USAGE ON . TO ‘test’@‘%’ WITH MAX_USER_CONNECTIONS 100;
flush privileges;