龙空技术网

如何在Debian11上安装 Mysql Server 8

wljslmz 163

前言:

此刻咱们对“debianpython安装”大概比较珍视,咱们都需要知道一些“debianpython安装”的相关内容。那么小编同时在网络上网罗了一些对于“debianpython安装””的相关内容,希望各位老铁们能喜欢,各位老铁们一起来学习一下吧!

MySQL 是一个开源的关系数据库管理系统,它是流行的关系型数据库之一。

Mysql 通常作为流行的 LAMP 或 LEMP(Linux、Apache/Nginx、MySQL/MariaDB、PHP/Python/Perl)堆栈的一部分安装,它实现了关系模型和结构化查询语言 (SQL) 来管理和查询数据。

在本指南中,我们将在 Debian 11 上安装 mysql 8。

1. 确保服务器是最新的

在开始之前,让我们确保我们的 debian 服务器是最新的,使用此命令更新服务器包:

sudo apt updatesudo apt upgrade -y

接下来,让我们安装我们在教程中需要的常用包

sudo apt install -y curl vim
2.为mysql 8安装设置repo

Mysql server 8 在默认的 Debian 存储库中不可用,mysql 团队提供了一个可下载的 .deb 文件,该文件将为 mysql server 8 安装配置存储库,使用以下命令下载它:

curl -LO 

您应该会看到与此几乎相似的输出:

$ curl -LO   % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current                                 Dload  Upload   Total   Spent    Left  Speed  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0100 35548  100 35548    0     0   104k      0 --:--:-- --:--:-- --:--:--  104k

下载完成后,我们需要安装下载的 deb 文件,使用此命令安装:

sudo dpkg -i ./mysql-apt-config_0.8.20-1_all.deb

这将打开一个配置窗口,提示您选择 mysql 服务器版本和其他组件,例如集群、共享客户端库或 MySQL 工作台。

现在因为我们只对 Mysql Server 安装感兴趣,所以保留默认(Mysql Server 和集群)设置并单击 OK 继续。

这是成功安装和配置的输出。

$ sudo dpkg -i ./mysql-apt-config_0.8.20-1_all.debsudo: unable to resolve host debiansrv.citizix.com: No address associated with hostname(Reading database ... 30001 files and directories currently installed.)Preparing to unpack .../mysql-apt-config_0.8.20-1_all.deb ...Unpacking mysql-apt-config (0.8.20-1) over (0.8.20-1) ...Setting up mysql-apt-config (0.8.20-1) ...Warning: apt-key should not be used in scripts (called from postinst maintainerscript of the package mysql-apt-config)Warning: apt-key is deprecated. Manage keyring files in trusted.gpg.d instead (see apt-key(8)).OK
3.安装Mysql 8服务器

现在已经添加了 repos 以包含 mysql 服务器,我们现在可以安装 mysql-server 包。

首先,刷新存储库以从添加的存储库中获取最新信息:

sudo apt update

然后使用以下命令安装 Mysql 8 Server:

sudo apt install -y mysql-server

输入您的管理员凭据,系统将安装 MySQL 服务器包、客户端包和数据库公共文件。

安装将提示您输入并确认 MySQL 数据库的 root 用户和密码。

使用此命令检查已安装包的信息以确认我们安装了我们想要的 mysql 版本:

$ apt-cache policy mysql-servermysql-server:  Installed: 8.0.27-1debian11  Candidate: 8.0.27-1debian11  Version table: *** 8.0.27-1debian11 500        500  bullseye/mysql-8.0 amd64 Packages        100 /var/lib/dpkg/status
4.启动和启用mysql服务

在 debian 中,Mysql 服务器默认是 styarted。检查服务的状态以确认它实际上正在运行:

$ sudo systemctl status mysqlsudo: unable to resolve host debiansrv.citizix.com: No address associated with hostname● mysql.service - MySQL Community Server     Loaded: loaded (/lib/systemd/system/mysql.service; enabled; vendor preset: enabled)     Active: active (running) since Wed 2021-11-24 04:47:23 UTC; 2min 31s ago       Docs: man:mysqld(8)                 Process: 15747 ExecStartPre=/usr/share/mysql-8.0/mysql-systemd-start pre (code=exited, status=0/>   Main PID: 15782 (mysqld)     Status: "Server is operational"      Tasks: 37 (limit: 4626)     Memory: 356.7M        CPU: 911ms     CGroup: /system.slice/mysql.service             └─15782 /usr/sbin/mysqldNov 24 04:47:22 debiansrv.citizix.com systemd[1]: Starting MySQL Community Server...Nov 24 04:47:23 debiansrv.citizix.com systemd[1]: Started MySQL Community Server.

在 Active: active (running) since ... 表示该服务是启动和运行。

要使服务在重新启动时启动,请使用以下命令:

sudo systemctl enable mysql

使用 journalctl 命令查看 MySQL 8 服务日志如下:

$ sudo journalctl -u mysql -xe$ sudo tail -f /var/log/mysql/mysqld.log
5. 测试 MySQL 安装

让我们使用以下命令检查 mysql 版本:

$ mysql -Vmysql  Ver 8.0.27 for Linux on x86_64 (MySQL Community Server - GPL)

现在您可以root 使用上面指定的 用户和密码登录。

$ mysql -u root -pEnter password:Welcome to the MySQL monitor.  Commands end with ; or \g.Your MySQL connection id is 8Server version: 8.0.27 MySQL Community Server - GPLCopyright (c) 2000, 2021, Oracle and/or its affiliates.Oracle is a registered trademark of Oracle Corporation and/or itsaffiliates. Other names may be trademarks of their respectiveowners.Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.mysql> select version();+-----------+| version() |+-----------+| 8.0.27    |+-----------+1 row in set (0.00 sec)mysql>

标签: #debianpython安装