01-课程介绍
![](https://img-blog.csdnimg.cn/41eed563feec464a90a8c9d69f6a9e3b.png)
02-存储引擎-MySQL体系结构
![](https://img-blog.csdnimg.cn/eb631454981046959aa855cc88672fc7.png)
![](https://img-blog.csdnimg.cn/74467a9236b645318fa4188918ad3ef7.png)
03存储引擎-简介
查询建表语句 --默认存储引擎:InnoDB
show create table account;
查询当前数据库支持的存储引擎
show engines;
04存储引擎-InnoDB介绍
开关为"ON": 表示每个innodb引擎的表都有一个idb表共享文件
![](https://img-blog.csdnimg.cn/acfbde4d6a20420c9a5cd0c7bafc1c89.png)
05存储引擎-MyISAM和Memory
面试常考(InnoDB与MyISAM区别)
06存储引擎的选择(一般就是InnoDB,其他两个在其他SQL中都有优化版)![](https://img-blog.csdnimg.cn/d842c9b3dc7b4357b3ad996f59bce660.png)
![](https://img-blog.csdnimg.cn/0adb00dbbfff4462a6809ffa832c21f2.png)
08MySQL安装(linux版本)
输入password的时候 不显示 我还以为没输入进去真贱啊
没开Linux防火墙3306的端口 不能远程链接
linux怎么允许3306端口通过防火墙,Centos7允许3306端口通过防火墙_倪振源的博客-CSDN博客
cnm,nmsl,教的什么j8玩意,链接虚拟机地址都不让我们查一下? 老子查了两个点才查出来!!!!
【MySQL】DataGrip连接linux中的MySQL_猫打球商店的博客-CSDN博客_datagrip 连接linux服务器
mariadb-libs 被 mysql-community-libs-compat-8.0.26-1.el7.x86_64 取代_别晃我的可乐的博客-CSDN博客_mariadb-libs Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (111)
直接停止再重启mysql服务
09索引-概述![](https://img-blog.csdnimg.cn/f29ea2b623734c52ae530c4853637876.png)
![](https://img-blog.csdnimg.cn/040132f2bad247039bd578408fd4d508.png)
10索引-结构-介绍
![](https://img-blog.csdnimg.cn/8f8820f7ec0c4d55966defec5837fa88.png)
![](https://img-blog.csdnimg.cn/6f01ffc7ca5741539b9cebf21e5c7b1f.png)
11索引-结构-Btree
![](https://img-blog.csdnimg.cn/5d7c1dc8d2d64c3db1c184a3121417f5.png)
![](https://img-blog.csdnimg.cn/0e791c58d5fb428e88903d0024502ce2.png)
![](https://img-blog.csdnimg.cn/4b4dd7536a64404fa91b1c2bcb6461a7.png)
数据结构可视化网站
12索引-结构-B+tree
![](https://img-blog.csdnimg.cn/995facbff4f7489397cbc7e1eb9444bc.png)
![](https://img-blog.csdnimg.cn/09a89234f4f847f59192731b96d57ae8.png)
![](https://img-blog.csdnimg.cn/9ba2ec24837a47c5aab6abf519c286f3.png)
13索引-结构-hash
![](https://img-blog.csdnimg.cn/8eb8813993c4488592a9908036482789.png)
![](https://img-blog.csdnimg.cn/9df56368f874402eb3765fc9773e4547.png)
14索-结构-思考题(why InnoDB引擎用 B+tree?)![](https://img-blog.csdnimg.cn/46401658c2cc4b1aa6daafe09667686f.png)
15索引-分类
![](https://img-blog.csdnimg.cn/94fe0ebb294443a7987112dd1d8845e4.png)
![](https://img-blog.csdnimg.cn/178677e118aa4a1395b6e53ef8b73fee.png)
![](https://img-blog.csdnimg.cn/bafb0220c2484f42a3629e755a823bbc.png)
![](https://img-blog.csdnimg.cn/0db42bdf24294a39ab601de211582fef.png)
16索引-思考题
17索引-语法
1. create index idx_user_name on tb_user(name);
2. create index idx_user_name on tb_user(name);
3. create index idx_user_pro_age_sta on tb_user(profession,age,status);
4. create index idx_user_email on tb_user(email);
18索引-性能分析-查看执行频次
![](https://img-blog.csdnimg.cn/74d71d7583674933aaebf9c795f48b39.png)
19索引-性能分析-慢查询日志
![](https://img-blog.csdnimg.cn/f2a38a2b35184e1d827aaf12c5ddc69a.png)
![](https://img-blog.csdnimg.cn/849817991ab041e0ac0e2fcb9fccf0ef.png)
![](https://img-blog.csdnimg.cn/513d6692c64648f49216ab102dc25f4c.png)
20索引-性能分析-showprofiles
![](https://img-blog.csdnimg.cn/654f0538c9844501a36952edc61bfdf6.png)
![](https://img-blog.csdnimg.cn/fab0d539ffed43948fb44db02758cd3b.png)
21索引-性能分析-explain
NULL:查询不妨问任何表时出现 select 'A'; system:访问系统表
const:根据主键/唯一索引访问; ref:使用非唯一索引查询
index:使用了索引,但会扫描遍历整个索引树 all:全表扫描
22索引-使用规则-验证索引效率
![](https://img-blog.csdnimg.cn/d785230588c54a37b91841655082dd8d.png)
23索引-使用规则-最左前缀法则
![](https://img-blog.csdnimg.cn/a4050a0bbee44ba194a73cb164df295c.png)
![](https://img-blog.csdnimg.cn/36d331b8f51743a895bebd67d797e7b2.png)
24索引-使用规则-索引失效情况一
![](https://img-blog.csdnimg.cn/87cb4950cdb249dcbb021c87dae3f8da.png)
![](https://img-blog.csdnimg.cn/aa592bcb9ca144c18863794ee4a809da.png)
![](https://img-blog.csdnimg.cn/286e8933913b4c81afaf287feadc758f.png)
25索引-使用规则-索引失效情况二
![](https://img-blog.csdnimg.cn/3ed8083e2f0e4bd093add96b47febec7.png)
![](https://img-blog.csdnimg.cn/5e752a42e10f433dac8a12afab6b1d33.png)
26索引-使用规则-SQL提示
(use只是一种建议 mysql是否接受不一定要看效率) use/ignore/force 建议/不用/强制使用
27索引-使用规则-覆盖索引&回表查询
![](https://img-blog.csdnimg.cn/7b9f1f64ca0a4e659a7d4f4f8a6ab020.png)
![](https://img-blog.csdnimg.cn/c22a204ec8074a16964a52e4f8a3bb84.png)
面试题:最佳方案:针对username-password建立联合索引 因为联合索引是二级索引,B+树叶子下面挂的是ID,所以执行select不需要回表查询 性能最好
28索引-使用规则-前缀索引
![](https://img-blog.csdnimg.cn/a2d8e97bfb594198bda498341e0b7926.png)
![](https://img-blog.csdnimg.cn/9dbc050fcb5a404dbd6c6e02ebe5f660.png)
29使用规则-单列&联合索引
创建索引(phone,name);要满足最左前缀法则;所以要考虑参数顺序
30索引-设计原则
31索引-小结
32SQL优化-插入数据
33SQL优化-主键优化(每页包含2~n)
34SQL优化-order by优化
35SQL优化-group by优化
36SQL优化-limit优化
37SQL优化-count优化(由存储引擎决定)
38SQL优化-update优化(避免行锁升级为表锁)
![](https://img-blog.csdnimg.cn/29e7caf0b12b414aa99dc7226a97879a.png)
39SQL优化-小结
![](https://img-blog.csdnimg.cn/8e3a5eed6e484b5a83adc35e90cc9697.png)
40视图-介绍及基本语法
41视图-检查选项(cascaded) (译为:级联的)
with cascaded check option;
视图 会在操作的时候检查是否满足where条件
并递归继续检查上面(依赖)的v2带cascaded的where 直到每个底层带cascaded的 都满足 才执行SQL;
42.进阶-视图-检查选项(local)
区别在于:local 当前v3没有检查选项 就不用管其它带(local的)依赖视图;
但是cascaded 就算v3没有也要管v2,v1(带cascaded检查选项的).