## 2.5 在 Linux 上安裝 MySQL
Linux 支持多種不同的 Linux 安裝解決方案. We recommend that you use one of the distributions from Oracle, for which several methods for installation are available:
**表 2.7 Linux 安裝方法和信息**
| 類型 | 設置方法 | 附加信息 |
|:---:|:---:|:---:|
| Apt | 啟用 [MySQL Apt repository](https://dev.mysql.com/downloads/repo/apt/) | [文檔](https://dev.mysql.com/doc/refman/8.0/en/linux-installation-apt-repo.html) |
| Yum | 啟用 [MySQL Yum repository](https://dev.mysql.com/downloads/repo/yum/) | [文檔](https://dev.mysql.com/doc/refman/8.0/en/linux-installation-yum-repo.html) |
| Zypper | 啟用 [MySQL SLES repository](https://dev.mysql.com/downloads/repo/suse/) | [文檔](https://dev.mysql.com/doc/refman/8.0/en/linux-installation-sles-repo.html) |
| RPM | [下載](https://dev.mysql.com/downloads/mysql/)通用包 | [文檔](https://dev.mysql.com/doc/refman/8.0/en/linux-installation-rpm.html) |
| DEB | [下載](https://dev.mysql.com/downloads/mysql/)通用包 | [文檔](https://dev.mysql.com/doc/refman/8.0/en/linux-installation-debian.html) |
| Generic | [下載](https://dev.mysql.com/downloads/mysql/)通用包 | [文檔](https://dev.mysql.com/doc/refman/8.0/en/binary-installation.html) |
| Source | 從[源碼](https://dev.mysql.com/downloads/mysql/)編譯 | [文檔](https://dev.mysql.com/doc/refman/8.0/en/source-installation.html) |
| Docker | 使用 Docker Hub, Docker Store, 或者 Oracle 鏡像托管 | [文檔](https://dev.mysql.com/doc/refman/8.0/en/linux-installation-docker.html) |
| Oracle Unbreakable Linux Network (Orace 堅不可摧的 Linux 網絡) | 使用 ULN 通道 | [文檔](https://dev.mysql.com/doc/refman/8.0/en/uln-installation.html) |
As an alternative, you can use the package manager on your system to automatically download and install MySQL with packages from the native software repositories of your Linux distribution. These native packages are often several versions behind the currently available release. You will also normally be unable to install development milestone releases (DMRs), as these are not usually made available in the native repositories. For more information on using the native package installers, see [Section 2.5.7, “Installing MySQL on Linux from the Native Software Repositories”](https://dev.mysql.com/doc/refman/8.0/en/linux-installation-native.html).
> **注意**
>
> 對于很多 Linux 安裝, 你希望將 MySQL 設置為在計算機啟動時自動啟動. Many of the native package installations perform this operation for you, but for source, binary and RPM solutions you may need to set this up separately. The required script, [mysql.server](https://dev.mysql.com/doc/refman/8.0/en/mysql-server.html), can be found in the `support-files` directory under the MySQL installation directory or in a MySQL source tree. You can install it as `/etc/init.d/mysql` for automatic MySQL startup and shutdown. See [Section 4.3.3, “**mysql.server** — MySQL Server Startup Script”](https://dev.mysql.com/doc/refman/8.0/en/mysql-server.html).
- 簡介
- 前言和法律條款
- 安裝和更新 MySQL
- 在 Linux 上安裝 MySQL
- 在 Linux 上使用 APT 庫安裝 MySQL
- 在 Linux 上使用 Docker 部署 MySQL
- 使用 Docker 部署 MySQL 服務器的基本步驟
- 使用 Docker 部署 MySQL 服務器的更多主題
- 教程
- 連接到服務器和從服務器斷開
- 輸入查詢
- 創建和使用數據庫
- 創建和選擇數據庫
- 創建表
- 將數據加載到表中
- 從表中檢索數據
- 選擇所有數據
- 選擇特定行
- 選擇指定列
- 行排序
- 日期計算
- 處理 NULL 值
- 模式匹配
- 計算行數
- 使用多個表
- 獲取數據庫和表的信息
- 在批處理模式使用 mysql
- 常見查詢示例
- 列的最大值
- 包含某一行最大值的記錄
- 每組中列的最大值
- 擁有某個字段的組間最大值的行
- 使用用戶自定義變量
- 使用外鍵
- 兩個鍵上搜索
- 計算每日訪問量
- 使用 AUTO_INCREMENT
- 在 Apache 中使用 MySQL
- MySQL 程序
- MySQL 客戶端程序
- mysql — MySQL 命令行客戶端
- 優化
- 優化概述
- 優化 SQL 語句
- 優化和索引
- 優化數據庫結構
- 優化 InnoDB 表
- 優化 MyISAM 表
- 優化 MEMORY 表
- 理解查詢執行計劃
- 控制查詢優化器
- 緩沖和緩存
- 優化鎖操作
- 優化 MySQL 服務器
- 測量性能 (Benchmarking)
- 檢查線程信息