如何在 Debian 9 Stretch Linux 上安装 MySQL 社区服务器
客观的
从 Debian 9 Stretch 开始,MySQL 不再是 Debian Linux 上的默认 SQL 数据库。目标是使用官方 MySQL 存储库安装 MySQL 社区服务器。
操作系统和软件版本
操作系统: – Debian 9 Stretch
软件: – MySQL 社区服务器 5.7.18
要求
需要对 Debian 服务器进行特权访问。
困难
简单的
惯例
# – 要求以root权限直接以root用户身份或使用
sudo
命令执行给定的linux命令$ – 要求以常规非特权用户身份执行给定的 Linux 命令
指示
获取存储库配置
在 Debian 9 Stretch 上安装 MySQL 社区服务器的最简单方法很可能是通过预先重新配置的官方 MySQL 存储库。这可以通过下载并安装 mysql-apt-config__*_all.deb
包来实现。
前往 https://dev.mysql.com/downloads/repo/apt/ 并下载最新的 MySQL APT 存储库包。例子:
$ wget https://dev.mysql.com/get/mysql-apt-config_0.8.6-1_all.deb
$ ls
mysql-apt-config_0.8.6-1_all.deb
安装存储库配置
现在您已经有了 MySQL APT Repository 软件包,请使用 gdebi 命令来安装它。如果您的系统上没有 gdebi
命令,您可以通过 # apt install gdebi-core
安装它:
# gdebi mysql-apt-config_0.8.6-1_all.deb
Reading package lists... Done
Building dependency tree
Reading state information... Done
Reading state information... Done
Auto configuration for MySQL APT Repo.
MySQL is a fast, stable and true multi-user, multi-threaded SQL database
server. SQL (Structured Query Language) is the most popular database query
language in the world. The main goals of MySQL are speed, robustness and
ease of use.
Do you want to install the software package? [y/N]:y
按照安装向导的说明,选择适当的 MySQL 服务器版本和存储库。默认值在大多数情况下应该有效。您始终可以通过直接编辑 /etc/apt/sources.list.d/mysql.list
源列表来查看选择手册。
安装MySQL服务器
在此阶段请确保运行:
# apt update
命令更新系统的软件包存储库。之后,剩下的就是使用 apt 命令安装 MySQL 软件包了。
# apt install mysql-server
上述命令还将获取并安装 MySQL 客户端。安装后,通过访问 MySQL 控制台确认安装:
# mysql -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 3
Server version: 5.7.18 MySQL Community Server (GPL)
Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql>