type
Post
status
Published
date
Dec 6, 2025
slug
mysql
summary
tags
推荐
category
技术分享
icon
password

基础

SQL

MySQL下载及安装

notion image

DDL操作(表体操作)

notion image

DML操作(表内容增删改操作)

notion image

DQL操作(表内容查询操作)

notion image

DCL操作(用户及权限操作)

注:用户详情在mysql.user表中存储
notion image

函数

字符串函数

notion image

数值函数

notion image

日期函数

notion image

流程函数

notion image

约束

notion image

多表查询

notion image
 

事务

事务操作 🖐️

notion image
notion image

事务的四大特性 🪢

notion image

并发事务问题 ❓

notion image

事务的隔离级别 ☢️

注:事务隔离级别越高,数据越安全,但是性能越低
  • 隔离级别:
notion image
  • 查看及操作
notion image

总结 ✌️

notion image

进阶

存储引擎

MySQL体系结构 🛖

  • 大纲
notion image
  • 分解
notion image

存储引擎简介 🤳

  • 存储引擎就是存储数据、建立索引、更新/查询数据等技术的实现方式 。存储引擎是基于表的,而不是基于库的,所以存储引擎也可被称为表类型。
notion image

InnoDB介绍 🔧

  • 特点
notion image
  • 逻辑储存结构
notion image

MyISAM和Memory 🕵️‍♀️

  • MyISAM特点
notion image
  • Memory特点
notion image
  • 三大存储引擎区别
notion image

存储引擎的选择 ➕

notion image

小结 ✌️

notion image

索引

索引介绍 🤳

notion image
notion image

索引结构 🛖

  • B-Tree
notion image
  • B+Tree(MySQL优化后)
notion image
  • hash
notion image
notion image

索引分类 🆎

notion image
notion image

索引语法 📇

notion image

性能分析 🔍

  • 查看执行频次
show global/session status like ‘com_______’;

  • 慢查询日志
查看是否开启慢查询日志开关: show variables like 'slow_query_log'; 慢查询日志记录了所有执行时间超过指定参数(long_query_tine,单位:秒,默认10秒)的所有SQL语句的日志。MySOL的慢查询日志默认没有开启,需要在MySOL的配置文件/etc/my.cnf)中配置如下信息: #开启MySOL慢日志查询开关 slow_query_log=1 #设置慢日志的时间为2秒,SOL语句执行时间超过2秒,就会视为慢查询,记录慢查询日志 long_query_time=2 配置完毕之后,通过以下指令重新启动MySQL服务器进行测试,查看慢日志文件中记录的信息 /var/lib/mysql/localhost-slow.log。

  • profile详情
show profiles 能够在做SQL优化时帮助我们了解时间都耗费到哪里去了。通过have profiling参数,能够看到当前MySQL是否支持profile操作: SELECT @@have profiling;
默认profiling是关闭的;
查看是否打开:
select @@profiling;
可以通过set语句在session/global级别开启profiling: SET profiling =1;
执行一系列的业务SQL的操作,然后通过如下指令查看指令的执行耗时: #查看每一条SOL的耗时基本情况
show profiles; #查看指定query id的SQL语句各个阶段的耗时情况
show profile for query query_id; #查看指定query id的SQL语句CPU的使用情况
show profile cpu for query query_id;

  • explain执行计划
EXPLAIN 或者 DESC命令获取MYSQL如何执行SELECT语句的信息,包括在SELECT语句执行过程中表如何连接和连接的顺序,语法:
#直接在select语句之前加上关键字 explain/desc
EXPLAIN SELECT 字段列表 FROM 表名 WHERE 条件;
notion image
notion image
✍️杂记🙃ggboy的fiddler笔记
Loading...