阿里云-云小站(无限量代金券发放中)
【腾讯云】云服务器、云数据库、COS、CDN、短信等热卖云产品特惠抢购

如何在Debian 10(Buster)Linux上安装MySQL

171次阅读
没有评论

共计 2085 个字符,预计需要花费 6 分钟才能阅读完成。

如何在 Debian 10(Buster)Linux 上安装 MySQL

到今天为止,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 选项。

如何在 Debian 10(Buster)Linux 上安装 MySQL

在本教程中,我们已选择 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 用户密码。

如何在 Debian 10(Buster)Linux 上安装 MySQL

下一个窗口将要求重新输入相同的密码。

MySQL 8 提供了扩展的密码安全选项。这是可选的,但我们建议使用此选项。

如何在 Debian 10(Buster)Linux 上安装 MySQL

让安装完成。

第 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>

正文完
星哥说事-微信公众号
post-qrcode
 0
星锅
版权声明:本站原创文章,由 星锅 于2022-01-22发表,共计2085字。
转载说明:除特殊说明外本站文章皆由CC-4.0协议发布,转载请注明出处。
【腾讯云】推广者专属福利,新客户无门槛领取总价值高达2860元代金券,每种代金券限量500张,先到先得。
阿里云-最新活动爆款每日限量供应
评论(没有评论)
验证码
【腾讯云】云服务器、云数据库、COS、CDN、短信等云产品特惠热卖中