1、mysql 添加用户访问权限
格式:
grant all on *.* to 'root'@'192.168.0.%' identified by 'root';
列子:
grant all on db1.b1 to '用户'@'%' identified by '密码';
授权root用户可以在任何 % ip下对db1数据库的b1表进行访问
2、添加增、删、改、查权限,授权本机操作权限
格式:
grant select ,insert ,update,delete on *.* to 'root'@'192.168.0.%' identified by 'root';
列子:
grant select,insert,update,delete,create,drop,alter on 数据库.* to 用户@'127.0.0.1' identified by '密码';
3、数据库主从备份,添加从库复制权限
grant replication slave on *.* to 'slave'@'192.168.1.%' identified by '123456';
4、添加操作权限,允许该数据库开启远程访问的权限
格式:
grant all privileges on 数据库.* to 用户@localhost identified by "密码" ;
列子:
grant all privileges on *.* to 'root'@'%' identified by '123456'
这里的123456为你给新增权限用户设置的密码,root用户 在 %代表所有ip条件下 可以操作数据库
注意:授权完记得刷新
FLUSH PRIVILEGES;
EXPLAIN :
type : system > const > eq_ref > ref > range > index > ALL
select_type:查询的复杂性:
simple:简单查询。
primary:复杂查询中最外层的 select,
subquery:包含在 select 中的子查询(不在 from 子句中),
derived:包含在 from 子句中的子查询