MySQL 教程

MySQL 是什么、为什么流行、以及这套教程怎么学。

Beginner
Key PointsMySQL 是最流行的开源关系型数据库:基于 SQL、支持事务、生态成熟,Web 后端几乎人手一个。

MySQL 是什么

MySQL is a relational database management system (RDBMS) from 1995. Data lives in tables of rows and columns, and you manipulate it with SQL. Originally built by MySQL AB in Sweden, it was acquired by Sun and then Oracle, yet the Community Edition stays open source.

Its core selling points are speed, stability and easy deployment. A single instance handles the full read/write load of a small or mid-size site, and with master-slave replication it scales out. Most LAMP/LNMP backends use it as the default store.

为什么用 MySQL

  • 开源免费 —— Community 版可直接用于生产,无授权费
  • 生态成熟 —— 几乎每种语言都有驱动(JDBC、PyMySQL、mysql2、go-sql-driver)
  • 事务支持 —— InnoDB 引擎提供 ACID、行级锁、崩溃恢复
  • 资料海量 —— 报错、调优、踩坑记录一搜一大把

版本与分支

分支维护方特点
MySQLOracle官方主线,8.0 起默认 utf8mb4、窗口函数
MariaDBMariaDB FoundationMySQL 原作者分叉,兼容协议、插件更开放
Percona ServerPercona偏向性能与运维工具

学习路线

  1. 装好 MySQL 并连上(安装 / 管理 / 连接)
  2. 建库建表、增删改查(第 5-15 章)
  3. 条件、排序、连接、事务(WHERE / ORDER BY / JOIN / 事务)
  4. 索引与调优(索引 / EXPLAIN)
  5. 工程落地:备份导入导出、防注入(第 30-32 章)
Examples target MySQL 8.0 with utf8mb4. 5.7 vs 8.0 differ in default auth plugin, window functions and descending indexes; caching_sha2_password auth errors are usually a version gap.

Friends & Partners