到今天为止, Debian Buster 是 Debian 操作系统的最新版本. 也称为 Debian 10. 较新的 Debian 版本在其存储库中默认使用了 MariaDB. 现在, 本教程将帮助您在 Debian 10 (Buster) Linux 系统上安装 MySQL 8 或 MySQL 5.7.
第 1 步 - 必要条件
使用 shell 访问权限登录 Debian 10 系统. 对于远程系统, 使用 SSH 连接. Windows 用户可以使用 Putty 或其他替代应用程序进行 SSH 连接.
SSH root@debian10
运行以下命令将当前包升级到最新版本.
- sudo apt update
- sudo apt upgrade
第 2 步 - 配置 MySQL PPA
MySQL 团队为 Debian Linux 提供官方 MySQL PPA. 您可以在 Debian 系统上下载并安装该软件包, 这会将 PPA 文件添加到您的系统中. 运行以下命令以启用 PPA.
- wget http://repo.mysql.com/mysql-apt-config_0.8.13-1_all.deb
- sudo dpkg -i MySQL-apt-config_0.8.13-1_all.deb
在安装 MySQL apt config 包期间, 它会提示选择 MySQL 版本进行安装. 选择要在系统上安装的 MySQL 8.0 或 5.7 选项.
在本教程中, 我们已选择 MySQL 5.7 在我的 Debian 系统上安装. 选择特定版本并需要更改配置后, 请使用以下命令.
sudo dpkg-reconfigure MySQL-apt-config
选择您选择的版本并保存.
第 3 步 - 在 Debian 10 上安装 MySQL
您的系统已准备好安装 MySQL. 运行以下命令在 Debian 计算机上安装 MySQL.
- sudo apt update
- sudo apt install MySQL-server
安装过程将提示 root 密码设置为默认值. 输入安全密码, 确认密码窗口. 这将是登录 MySQL 服务器所需的 MySQL root 用户密码.
下一个窗口将要求重新输入相同的密码.
MySQL 8 提供了扩展的密码安全选项. 这是可选的, 但我们建议使用此选项.
让安装完成.
第 4 步 - 安全 MySQL 安装
在系统上执行以下命令以对数据库服务器进行安全性更改. 这会提示一些问题. 高安全性提供所有答案是肯定的.
如果没有启动, 首先启动 MySQL 服务:
sudo systemctl restart MySQL.service
然后运行以下命令:
sudo mysql_secure_installation
按照屏幕上的指示进行操作
- Securing the MySQL server deployment.
- Enter password for user root:
- VALIDATE PASSWORD COMPONENT can be used to test passwords
- and improve security. It checks the strength of password
- and allows the users to set only those passwords which are
- secure enough. Would you like to setup VALIDATE PASSWORD component?
- Press y|Y for Yes, any other key for No: y
- There are three levels of password validation policy:
- LOW Length>= 8
- MEDIUM Length>= 8, numeric, mixed case, and special characters
- STRONG Length>= 8, numeric, mixed case, special characters and dictionary file
- Please enter 0 = LOW, 1 = MEDIUM and 2 = STRONG: 2
- [...]
选择 MEDIUM 或 STRONG 的密码验证策略. 之后, 该过程将要求更改密码. 您可以选择更复杂的密码. 按照其他选项完成向导.
第 5 步 - 连接 MySQL
MySQL 服务器已安装在您的系统上. 现在使用命令行连接到 MySQL 数据库.
- MySQL -u root -p
- Enter password:
- Welcome to the MySQL monitor. Commands end with ; or \g.
- Your MySQL connection id is 8
- Server version: 8.0.17 MySQL Community Server - GPL
- Copyright (c) 2000, 2019, 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>
来源: http://www.linuxidc.com/Linux/2019-07/159582.htm