当前位置: 首页 > news >正文

MySQL包安装 -- Debian系列(Apt资源库安装MySQL)

文章目录

      • 2.2.2 Debian系列
        • 2.2.2.1 Apt资源库安装MySQL
          • 2.2.2.1.1 MySQL 8.0
          • 2.2.2.1.2 MySQL 8.4

2.2.2 Debian系列

2.2.2.1 Apt资源库安装MySQL
2.2.2.1.1 MySQL 8.0

在“Ubuntu”上安装MySQL:

root@ubuntu2404:~# apt-cache madison mysql-server
mysql-server | 8.0.43-0ubuntu0.24.04.2 | https://mirrors.aliyun.com/ubuntu noble-updates/main amd64 Packages
mysql-server | 8.0.43-0ubuntu0.24.04.1 | https://mirrors.aliyun.com/ubuntu noble-security/main amd64 Packages
mysql-server | 8.0.36-2ubuntu3 | https://mirrors.aliyun.com/ubuntu noble/main amd64 Packagesroot@ubuntu2404:~# apt install -y mysql-serverroot@ubuntu2404:~# systemctl enable --now mysqlroot@ubuntu2404:~# ls /var/lib/mysqlauto.cnf        ca-key.pem       '#ib_16384_0.dblwr'  '#innodb_redo'        private_key.pem   ubuntu2404.pidbinlog.000001   ca.pem           '#ib_16384_1.dblwr'  '#innodb_temp'        public_key.pem    undo_001binlog.000002   client-cert.pem   ib_buffer_pool       mysql                server-cert.pem   undo_002binlog.000003   client-key.pem    ibdata1              mysql.ibd            server-key.pembinlog.index    debian-5.7.flag   ibtmp1               performance_schema   sysroot@ubuntu2404:~# mysql -V
mysql  Ver 8.0.43-0ubuntu0.24.04.2 for Linux on x86_64 ((Ubuntu))root@ubuntu2404:~# systemctl status mysql
● mysql.service - MySQL Community ServerLoaded: loaded (/usr/lib/systemd/system/mysql.service; enabled; preset: enabled)Active: active (running) since Wed 2025-10-01 16:34:50 CST; 35s agoMain PID: 1925 (mysqld)Status: "Server is operational"Tasks: 38 (limit: 2210)Memory: 363.8M (peak: 378.0M)CPU: 1.178sCGroup: /system.slice/mysql.service└─1925 /usr/sbin/mysqldOct 01 16:34:50 ubuntu2404 systemd[1]: Starting mysql.service - MySQL Community Server...
Oct 01 16:34:50 ubuntu2404 systemd[1]: Started mysql.service - MySQL Community Server.root@ubuntu2404:~# mysql
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 8
Server version: 8.0.43-0ubuntu0.24.04.2 (Ubuntu)Copyright (c) 2000, 2025, Oracle and/or its affiliates.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> status
--------------
mysql  Ver 8.0.43-0ubuntu0.24.04.2 for Linux on x86_64 ((Ubuntu))Connection id:		8
Current database:	
Current user:		root@localhost
SSL:			Not in use
Current pager:		stdout
Using outfile:		''
Using delimiter:	;
Server version:		8.0.43-0ubuntu0.24.04.2 (Ubuntu)
Protocol version:	10
Connection:		Localhost via UNIX socket
Server characterset:	utf8mb4
Db     characterset:	utf8mb4
Client characterset:	utf8mb4
Conn.  characterset:	utf8mb4
UNIX socket:		/var/run/mysqld/mysqld.sock
Binary data as:		Hexadecimal
Uptime:			1 min 19 secThreads: 2  Questions: 5  Slow queries: 0  Opens: 119  Flush tables: 3  Open tables: 38  Queries per second avg: 0.063
--------------mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
| sys                |
+--------------------+
4 rows in set (0.00 sec)mysql> exit
Bye

在“Debian 11/12”上安装MySQL:

去“https://www.mysql.com/”网站下载,选择“DOWNLOADS”,如图19所示。

t19

图19 下载APT仓库包

选择“MySQL Community (GPL) Downloads”,如图20所示。

t20

图20 下载APT仓库包

选择“MySQL APT Repository(MySQL APT资源库)”,如图21所示。

t21

图21 下载APT仓库包

然后选择”DEB Package“后面的”Download“,如图22所示。

t22

图22 下载APT仓库包

root@debian12:~# wget https://dev.mysql.com/get/mysql-apt-config_0.8.34-1_all.debroot@debian12:~# dpkg -i mysql-apt-config_0.8.34-1_all.deb
Selecting previously unselected package mysql-apt-config.
dpkg: regarding mysql-apt-config_0.8.34-1_all.deb containing mysql-apt-config, pre-dependency problem:mysql-apt-config pre-depends on gnupggnupg is not installed.  # 提示没有安装gnupgdpkg: error processing archive mysql-apt-config_0.8.34-1_all.deb (--install):pre-dependency problem - not installing mysql-apt-config
Errors were encountered while processing:mysql-apt-config_0.8.34-1_all.debroot@debian12:~# apt install -y gnupgroot@debian12:~# dpkg -i mysql-apt-config_0.8.34-1_all.deb

使用箭头键导航到 “MySQL Server & Cluster (Currently selected: mysql-8.4-lts)” 选项,然后按下 Enter 键,这将允许你选择具体的 MySQL 服务器版本,如图23所示。

t23

图23 选择MySQL版本

在版本选择界面中,选择 “mysql-8.0” 版本并按 Enter,如图24所示。

t24

图24 选择MySQL版本

使用箭头键导航到 “Ok” 选项,按下 Enter 键,确认并保存配置,如图25所示。

t25

图25 确认选择

# 替换国内镜像源
sed -i.bak 's|http://repo.mysql.com|https://mirrors.nju.edu.cn/mysql|g' /etc/apt/sources.list.d/mysql.listroot@debian12:~# apt updateroot@debian12:~# apt-cache madison mysql-community-server
mysql-community-server | 8.0.43-1debian12 | http://repo.mysql.com/apt/debian bookworm/mysql-8.0 amd64 Packages
mysql-community | 8.0.43-1debian12 | http://repo.mysql.com/apt/debian bookworm/mysql-8.0 Sourcesroot@debian12:~# apt install -y mysql-community-server

输入MySQL root用户密码,然后按下 Enter 键,如图26所示。

t26

图26 输入MySQL root用户密码

在下面提示直接按下 Enter 键,如图27所示。

t27

图27 确认提示信息

选择“Use Strong Password Encryption (RECOMMENDED)”,然后按下 Enter 键,如图28所示。

t28

图28 选择默认身份验证插件

root@debian12:~# systemctl enable --now mysqlroot@debian12:~# ls /var/lib/mysqlauto.cnf	 ca.pem		      ib_buffer_pool   mysql		    server-cert.pembinlog.000001	 client-cert.pem      ibdata1	       mysql.ibd	    server-key.pembinlog.000002	 client-key.pem       ibtmp1	       performance_schema   sysbinlog.index	'#ib_16384_0.dblwr'  '#innodb_redo'    private_key.pem	    undo_001ca-key.pem	'#ib_16384_1.dblwr'  '#innodb_temp'    public_key.pem	    undo_002root@debian12:~# mysql -V
mysql  Ver 8.0.43 for Linux on x86_64 (MySQL Community Server - GPLroot@debian12:~# systemctl status mysql
● mysql.service - MySQL Community ServerLoaded: loaded (/lib/systemd/system/mysql.service; enabled; preset: enabled)Active: active (running) since Wed 2025-10-01 17:29:03 CST; 50s agoDocs: man:mysqld(8)http://dev.mysql.com/doc/refman/en/using-systemd.htmlMain PID: 1923 (mysqld)Status: "Server is operational"Tasks: 38 (limit: 2273)Memory: 368.3MCPU: 1.349sCGroup: /system.slice/mysql.service└─1923 /usr/sbin/mysqldOct 01 17:29:02 debian12 systemd[1]: Starting mysql.service - MySQL Community Server...
Oct 01 17:29:03 debian12 systemd[1]: Started mysql.service - MySQL Community Server.root@debian12:~# mysql
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 8
Server version: 8.0.43 MySQL Community Server - GPLCopyright (c) 2000, 2025, Oracle and/or its affiliates.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> status
--------------
mysql  Ver 8.0.43 for Linux on x86_64 (MySQL Community Server - GPL)Connection id:		8
Current database:	
Current user:		root@localhost
SSL:			Not in use
Current pager:		stdout
Using outfile:		''
Using delimiter:	;
Server version:		8.0.43 MySQL Community Server - GPL
Protocol version:	10
Connection:		Localhost via UNIX socket
Server characterset:	utf8mb4
Db     characterset:	utf8mb4
Client characterset:	utf8mb4
Conn.  characterset:	utf8mb4
UNIX socket:		/var/run/mysqld/mysqld.sock
Binary data as:		Hexadecimal
Uptime:			1 min 16 secThreads: 2  Questions: 5  Slow queries: 0  Opens: 119  Flush tables: 3  Open tables: 38  Queries per second avg: 0.065
--------------mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
| sys                |
+--------------------+
4 rows in set (0.00 sec)mysql> exit
Bye
2.2.2.1.2 MySQL 8.4

去“https://www.mysql.com/”网站下载,选择“DOWNLOADS”,如图29所示。

t29

图29 下载APT仓库包

选择“MySQL Community (GPL) Downloads”,如图30所示。

t30

图30 下载APT仓库包

选择“MySQL APT Repository(MySQL APT资源库)”,如图31所示。

t31

图31 下载APT仓库包

然后选择”DEB Package“后面的”Download“,如图32所示。

t32

图32 下载APT仓库包

在“Ubuntu"上安装MySQL:

root@ubuntu2404:~# wget https://dev.mysql.com/get/mysql-apt-config_0.8.34-1_all.debroot@ubuntu2404:~# dpkg -i mysql-apt-config_0.8.34-1_all.deb

使用箭头键导航到 “MySQL Server & Cluster (Currently selected: mysql-8.4-lts)” 选项,然后按下 Enter 键,这将允许你选择具体的 MySQL 服务器版本,如图33所示。

t33

图33 选择MySQL版本

在版本选择界面中,选择 “mysql-8.4-lts” 版本(或其他你想要的版本)并按 Enter,如图34所示。

t34

图34 选择MySQL版本

使用箭头键导航到 “Ok” 选项,按下 Enter 键,确认并保存配置,如图35所示。

t35

图35 确认选择

# 替换国内镜像源
sed -i.bak 's|http://repo.mysql.com|https://mirrors.nju.edu.cn/mysql|g' /etc/apt/sources.list.d/mysql.listroot@ubuntu2404:~# apt updateroot@ubuntu2404:~# apt-cache madison mysql-community-server
mysql-community-server | 8.4.6-1ubuntu24.04 | http://repo.mysql.com/apt/ubuntu noble/mysql-8.4-lts amd64 Packages
mysql-community | 8.4.6-1ubuntu24.04 | http://repo.mysql.com/apt/ubuntu noble/mysql-8.4-lts Sourcesroot@ubuntu2404:~# apt install -y  mysql-community-server

输入MySQL root用户密码,然后按下 Enter 键,如图36所示。

t36

图36 输入MySQL root用户密码

root@ubuntu2404:~# systemctl enable --now mysqlroot@ubuntu2404:~# ls /var/lib/mysqlauto.cnf        ca.pem               ib_buffer_pool   mysql                   public_key.pem    undo_002binlog.000001   client-cert.pem      ibdata1          mysql.ibd               server-cert.pembinlog.000002   client-key.pem       ibtmp1           mysql_upgrade_history   server-key.pembinlog.index   '#ib_16384_0.dblwr'  '#innodb_redo'    performance_schema      sysca-key.pem     '#ib_16384_1.dblwr'  '#innodb_temp'    private_key.pem         undo_001root@ubuntu2404:~# mysql -V
mysql  Ver 8.4.6 for Linux on x86_64 (MySQL Community Server - GPL)root@ubuntu2404:~# systemctl status mysql
● mysql.service - MySQL Community ServerLoaded: loaded (/usr/lib/systemd/system/mysql.service; enabled; preset: enabled)Active: active (running) since Fri 2025-10-03 10:55:17 CST; 36s agoDocs: man:mysqld(8)http://dev.mysql.com/doc/refman/en/using-systemd.htmlMain PID: 2134 (mysqld)Status: "Server is operational"Tasks: 35 (limit: 2210)Memory: 420.3M (peak: 434.3M)CPU: 1.415sCGroup: /system.slice/mysql.service└─2134 /usr/sbin/mysqldOct 03 10:55:16 ubuntu2404 systemd[1]: Starting mysql.service - MySQL Community Server...
Oct 03 10:55:17 ubuntu2404 systemd[1]: Started mysql.service - MySQL Community Server.root@ubuntu2404:~# mysql
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 8
Server version: 8.4.6 MySQL Community Server - GPLCopyright (c) 2000, 2025, Oracle and/or its affiliates.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> status
--------------
mysql  Ver 8.4.6 for Linux on x86_64 (MySQL Community Server - GPL)Connection id:		8
Current database:	
Current user:		root@localhost
SSL:			Not in use
Current pager:		stdout
Using outfile:		''
Using delimiter:	;
Server version:		8.4.6 MySQL Community Server - GPL
Protocol version:	10
Connection:		Localhost via UNIX socket
Server characterset:	utf8mb4
Db     characterset:	utf8mb4
Client characterset:	utf8mb4
Conn.  characterset:	utf8mb4
UNIX socket:		/var/run/mysqld/mysqld.sock
Binary data as:		Hexadecimal
Uptime:			57 secThreads: 2  Questions: 6  Slow queries: 0  Opens: 119  Flush tables: 3  Open tables: 38  Queries per second avg: 0.105
--------------mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
| sys                |
+--------------------+
4 rows in set (0.01 sec)mysql> exit
Bye

在"Debian 11/12"上安装MySQL:

root@debian12:~# wget https://dev.mysql.com/get/mysql-apt-config_0.8.34-1_all.debroot@debian12:~# dpkg -i  mysql-apt-config_0.8.34-1_all.deb
dpkg: regarding mysql-apt-config_0.8.34-1_all.deb containing mysql-apt-config, pre-dependency problem:mysql-apt-config pre-depends on gnupggnupg is not installed. # 提示没有安装gnupgdpkg: error processing archive mysql-apt-config_0.8.34-1_all.deb (--install):pre-dependency problem - not installing mysql-apt-config
Errors were encountered while processing:mysql-apt-config_0.8.34-1_all.debroot@debian12:~# apt install -y gnupgroot@debian12:~# dpkg -i  mysql-apt-config_0.8.34-1_all.deb

使用箭头键导航到 “MySQL Server & Cluster (Currently selected: mysql-8.4-lts)” 选项,然后按下 Enter 键,这将允许你选择具体的 MySQL 服务器版本,如图37所示。

t37

图37 选择MySQL版本

在版本选择界面中,选择 “mysql-8.4-lts” 版本(或其他你想要的版本)并按 Enter,如图38所示。

t38

图38 选择MySQL版本

使用箭头键导航到 “Ok” 选项,按下 Enter 键,确认并保存配置,如图39所示。

t39

图39 确认选择

# 替换国内镜像源
sed -i.bak 's|http://repo.mysql.com|https://mirrors.nju.edu.cn/mysql|g' /etc/apt/sources.list.d/mysql.listroot@debian12:~# apt updateroot@debian12:~# apt-cache madison mysql-community-server
mysql-community-server | 8.4.6-1debian12 | http://repo.mysql.com/apt/debian bookworm/mysql-8.4-lts amd64 Packages
mysql-community | 8.4.6-1debian12 | http://repo.mysql.com/apt/debian bookworm/mysql-8.4-lts Sourcesroot@debian12:~# apt install -y  mysql-community-server

输入MySQL root用户密码,然后按下 Enter 键,如图40所示。

t40

图40 输入MySQL root用户密码

root@debian12:~# systemctl enable --now mysqlroot@debian12:~# ls /var/lib/mysqlauto.cnf	 ca.pem		      ib_buffer_pool   mysql		       public_key.pem	 undo_002binlog.000001	 client-cert.pem      ibdata1	       mysql.ibd	       server-cert.pembinlog.000002	 client-key.pem       ibtmp1	       mysql_upgrade_history   server-key.pembinlog.index	'#ib_16384_0.dblwr'  '#innodb_redo'    performance_schema      sysca-key.pem	'#ib_16384_1.dblwr'  '#innodb_temp'    private_key.pem	       undo_001root@debian12:~# mysql -V
mysql  Ver 8.4.6 for Linux on x86_64 (MySQL Community Server - GPL)root@debian12:~# systemctl status mysql
● mysql.service - MySQL Community ServerLoaded: loaded (/lib/systemd/system/mysql.service; enabled; preset: enabled)Active: active (running) since Fri 2025-10-03 11:02:19 CST; 29s agoDocs: man:mysqld(8)http://dev.mysql.com/doc/refman/en/using-systemd.htmlMain PID: 1907 (mysqld)Status: "Server is operational"Tasks: 35 (limit: 2273)Memory: 427.9MCPU: 1.051sCGroup: /system.slice/mysql.service└─1907 /usr/sbin/mysqldOct 03 11:02:18 debian12 systemd[1]: Starting mysql.service - MySQL Community Server...
Oct 03 11:02:19 debian12 systemd[1]: Started mysql.service - MySQL Community Server.root@debian12:~# mysql
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 8
Server version: 8.4.6 MySQL Community Server - GPLCopyright (c) 2000, 2025, Oracle and/or its affiliates.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> status
--------------
mysql  Ver 8.4.6 for Linux on x86_64 (MySQL Community Server - GPL)Connection id:		8
Current database:	
Current user:		root@localhost
SSL:			Not in use
Current pager:		stdout
Using outfile:		''
Using delimiter:	;
Server version:		8.4.6 MySQL Community Server - GPL
Protocol version:	10
Connection:		Localhost via UNIX socket
Server characterset:	utf8mb4
Db     characterset:	utf8mb4
Client characterset:	utf8mb4
Conn.  characterset:	utf8mb4
UNIX socket:		/var/run/mysqld/mysqld.sock
Binary data as:		Hexadecimal
Uptime:			51 secThreads: 2  Questions: 6  Slow queries: 0  Opens: 119  Flush tables: 3  Open tables: 38  Queries per second avg: 0.117
--------------mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
| sys                |
+--------------------+
4 rows in set (0.00 sec)mysql> exit
Bye
http://www.dtcms.com/a/454828.html

相关文章:

  • 同安网站建设网站开发用了哪些知识要点
  • 京东商品详情API深度技术解析与应用全景图
  • 【数值分析】09-非线性方程的求根方法-简单迭代法求根(2)
  • 彩票网站开发制作模版企业建设营销型网站步骤
  • 包头北京网站建设视觉设计主要学什么
  • 怎样把自己做的网站发到网上域名查询网站信息
  • 为什么 CompletableDeferred 不适合数据流---》数据流的正确解决方案
  • 大连模版网站网页紧急升级维护中升级
  • 向量表与重定位(Cortex‑M 系列)
  • 网站空间是不是服务器河南省建设厅举报网站
  • Linux中查询运行进程的命令
  • 四川建设厅网站施工员证查询建设学校网站多钱
  • 微信小程序连接OneNET需要生成token,简单快速的办法
  • 做网站还是自媒体更适合赚钱wordpress主题 游戏
  • Python3 tuple 函数
  • 网站建设公司江苏wordpress下载类主题
  • 作者新游戏1.2
  • 中国建设银行网站登陆免费个人网页模板
  • 网站建设怎么赚钱深圳市电商网站建设企业
  • 【Linux】线程概念与控制(1)
  • 网站做5年有多少流量网站关键词如何布局
  • H5网站开发工程师网站建设网站形象
  • 狮岭做包包的网站优秀网站推荐
  • Python chr() 函数
  • wordpress网站文章排版插件镇海建设银行网站
  • 用cms建网站ps网站首页设计图制作教程
  • wordpress 浮动播放器seo工作前景如何
  • wordpress做什么网站好网站推广策略有哪些
  • 昆山外贸公司网站建设流程国内做网站哪家公司好
  • 沧州各种网站wordpress首页循环