2.2.2.2 离线DEB包安装MySQL
2.2.2.2.1 MySQL 8.0
去“https://www.mysql.com/”网站下载,选择“DOWNLOADS”,如图41所示。
图41 下载MySQL DEB包
选择“MySQL Community (GPL) Downloads”,如图42所示。
图42 下载MySQL DEB包
选择“MySQL Community Server(MySQL社区服务器)”,如图43所示。
图43 下载MySQL DEB包
在“Ubuntu 24.04”上安装MySQL:
"Select Version(选择版本)"为:8.0.43,“Select Operating System(选择操作系统)”为:Ubuntu Linux,"Select OS Version(选择操作系统版本)"为:根据版本选择,"Ubuntu 24.04"选择"Ubuntu Linux 24.04 (x86 , 64-bit)",然后选择”DEB Bundle“后面的”Download“,如图44所示。
图44 下载MySQL DEB包
root@ubuntu2404:~# wget https://cdn.mysql.com//Downloads/MySQL-8.0/mysql-server_8.0.43-1ubuntu24.04_amd64.deb-bundle.tar
root@ubuntu2404:~# tar xf mysql-server_8.0.43-1ubuntu24.04_amd64.deb-bundle.tar
方法1:dpkg命令安装,要按下面执行的顺序安装,否则会报错
root@ubuntu2404:~# dpkg -i mysql-community-client-plugins_8.0.43-1ubuntu24.04_amd64.deb
root@ubuntu2404:~# dpkg -i mysql-community-client-core_8.0.43-1ubuntu24.04_amd64.deb
root@ubuntu2404:~# dpkg -i mysql-common_8.0.43-1ubuntu24.04_amd64.deb
root@ubuntu2404:~# dpkg -i mysql-community-client_8.0.43-1ubuntu24.04_amd64.deb
root@ubuntu2404:~# dpkg -i libmysqlclient21_8.0.43-1ubuntu24.04_amd64.deb
root@ubuntu2404:~# dpkg -i libmysqlclient-dev_8.0.43-1ubuntu24.04_amd64.deb
root@ubuntu2404:~# dpkg -i mysql-client_8.0.43-1ubuntu24.04_amd64.deb
root@ubuntu2404:~# dpkg -i mysql-community-server-core_8.0.43-1ubuntu24.04_amd64.deb
Selecting previously unselected package mysql-community-server-core.
(Reading database ... 87176 files and directories currently installed.)
Preparing to unpack mysql-community-server-core_8.0.43-1ubuntu24.04_amd64.deb ...
Unpacking mysql-community-server-core (8.0.43-1ubuntu24.04) ...
dpkg: dependency problems prevent configuration of mysql-community-server-core:
mysql-community-server-core depends on libmecab2 (>= 0.996); however:
Package libmecab2 is not installed. # 提示,没有安装libmecab2依赖包
dpkg: error processing package mysql-community-server-core (--install):
dependency problems - leaving unconfigured
Processing triggers for libc-bin (2.39-0ubuntu8.6) ...
Processing triggers for man-db (2.12.0-4build2) ...
Errors were encountered while processing:
mysql-community-server-core
root@ubuntu2404:~# apt install -y libmecab2
root@ubuntu2404:~# dpkg -i mysql-community-server-core_8.0.43-1ubuntu24.04_amd64.deb
root@ubuntu2404:~# dpkg -i mysql-community-server_8.0.43-1ubuntu24.04_amd64.deb
输入MySQL root用户密码,然后按下 Enter 键,如图45所示。
图45 输入MySQL root用户密码
在下面提示直接按下 Enter 键,如图46所示。
图46 确认提示信息
选择“Use Strong Password Encryption (RECOMMENDED)”,然后按下 Enter 键,如图47所示。
图47 选择默认身份验证插件
root@ubuntu2404:~# dpkg -i mysql-server_8.0.43-1ubuntu24.04_amd64.deb
方法2:从“https://dev.mysql.com/doc/refman/8.0/en/linux-installation-debian.html”网址看到安装文档:
root@ubuntu2404:~# apt install -y libmecab2
# 预先配置 MySQL 服务器软件包:
root@ubuntu2404:~# dpkg-preconfigure mysql-community-server_*.deb
# 出现图45-47界面,按上面的提示设置。
root@ubuntu2404:~# dpkg -i mysql-{common,community-client-plugins,community-client-core,community-client,client,community-server-core,community-server,server}_*.deb
继续安装MySQL:
root@ubuntu2404:~# systemctl enable --now mysql
root@ubuntu2404:~# ls /var/lib/mysql
auto.cnf ca.pem ib_buffer_pool mysql server-cert.pem
binlog.000001 client-cert.pem ibdata1 mysql.ibd server-key.pem
binlog.000002 client-key.pem ibtmp1 performance_schema sys
binlog.index '#ib_16384_0.dblwr' '#innodb_redo' private_key.pem undo_001
ca-key.pem '#ib_16384_1.dblwr' '#innodb_temp' public_key.pem undo_002
root@ubuntu2404:~# mysql -V
mysql Ver 8.0.43 for Linux on x86_64 (MySQL Community Server - GPL)
root@ubuntu2404:~# systemctl status mysql
● mysql.service - MySQL Community Server
Loaded: loaded (/usr/lib/systemd/system/mysql.service; enabled; preset: enabled)
Active: active (running) since Wed 2025-10-01 18:25:03 CST; 2min 21s ago
Docs: man:mysqld(8)
http://dev.mysql.com/doc/refman/en/using-systemd.html
Main PID: 1960 (mysqld)
Status: "Server is operational"
Tasks: 37 (limit: 2210)
Memory: 362.7M (peak: 376.8M)
CPU: 3.042s
CGroup: /system.slice/mysql.service
└─1960 /usr/sbin/mysqld
Oct 01 18:25:02 ubuntu2404 systemd[1]: Starting mysql.service - MySQL Community Server...
Oct 01 18:25:03 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 MySQL Community Server - GPL
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 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: 2 min 56 sec
Threads: 2 Questions: 5 Slow queries: 0 Opens: 119 Flush tables: 3 Open tables: 38 Queries per second avg: 0.028
--------------
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| sys |
+--------------------+
4 rows in set (0.01 sec)
mysql> exit
Bye
在“Ubuntu 22.04”上安装MySQL:
"Select Version(选择版本)"为:8.0.43,“Select Operating System(选择操作系统)”为:Ubuntu Linux,"Select OS Version(选择操作系统版本)"为:根据版本选择,"Ubuntu 22.04"选择"Ubuntu Linux 22.04 (x86 , 64-bit)",然后选择”DEB Bundle“后面的”Download“,如图48所示。
图48 下载MySQL DEB包
root@ubuntu2204:~# wget https://cdn.mysql.com//Downloads/MySQL-8.0/mysql-server_8.0.43-1ubuntu22.04_amd64.deb-bundle.tar
root@ubuntu2204:~# tar xf mysql-server_8.0.43-1ubuntu22.04_amd64.deb-bundle.tar
方法1:dpkg命令安装,要按下面执行的顺序安装,否则会报错
root@ubuntu2204:~# dpkg -i mysql-community-client-plugins_8.0.43-1ubuntu22.04_amd64.deb
root@ubuntu2204:~# dpkg -i mysql-community-client-core_8.0.43-1ubuntu22.04_amd64.deb
root@ubuntu2204:~# dpkg -i mysql-common_8.0.43-1ubuntu22.04_amd64.deb
root@ubuntu2204:~# dpkg -i mysql-community-client_8.0.43-1ubuntu22.04_amd64.deb
root@ubuntu2204:~# dpkg -i libmysqlclient21_8.0.43-1ubuntu22.04_amd64.deb
root@ubuntu2204:~# dpkg -i libmysqlclient-dev_8.0.43-1ubuntu22.04_amd64.deb
root@ubuntu2204:~# dpkg -i mysql-client_8.0.43-1ubuntu22.04_amd64.deb
root@ubuntu2204:~# dpkg -i mysql-community-server-core_8.0.43-1ubuntu22.04_amd64.deb
Selecting previously unselected package mysql-community-server-core.
(Reading database ... 74799 files and directories currently installed.)
Preparing to unpack mysql-community-server-core_8.0.43-1ubuntu22.04_amd64.deb ...
Unpacking mysql-community-server-core (8.0.43-1ubuntu22.04) ...
dpkg: dependency problems prevent configuration of mysql-community-server-core:
mysql-community-server-core depends on libmecab2 (>= 0.996); however:
Package libmecab2 is not installed. # 提示,没有安装libmecab2依赖包
dpkg: error processing package mysql-community-server-core (--install):
dependency problems - leaving unconfigured
Processing triggers for libc-bin (2.35-0ubuntu3.8) ...
Processing triggers for man-db (2.10.2-1) ...
Errors were encountered while processing:
mysql-community-server-core
root@ubuntu2204:~# apt install -y libmecab2
root@ubuntu2204:~# dpkg -i mysql-community-server-core_8.0.43-1ubuntu22.04_amd64.deb
root@ubuntu2204:~# dpkg -i mysql-community-server_8.0.43-1ubuntu22.04_amd64.deb
# 出现图45-47界面,按上面的提示设置.
root@ubuntu2204:~# dpkg -i mysql-server_8.0.43-1ubuntu22.04_amd64.deb
方法2:从“https://dev.mysql.com/doc/refman/8.0/en/linux-installation-debian.html”网址看到安装文档:
root@ubuntu2204:~# apt install -y libmecab2
# 预先配置 MySQL 服务器软件包:
root@ubuntu2204:~# dpkg-preconfigure mysql-community-server_*.deb
# 出现图45-47界面,按上面的提示设置。
root@ubuntu2204:~# dpkg -i mysql-{common,community-client-plugins,community-client-core,community-client,client,community-server-core,community-server,server}_*.deb
继续安装MySQL:
root@ubuntu2204:~# systemctl enable --now mysql
root@ubuntu2204:~# ls /var/lib/mysql
auto.cnf ca.pem ib_buffer_pool mysql server-cert.pem
binlog.000001 client-cert.pem ibdata1 mysql.ibd server-key.pem
binlog.000002 client-key.pem ibtmp1 performance_schema sys
binlog.index '#ib_16384_0.dblwr' '#innodb_redo' private_key.pem undo_001
ca-key.pem '#ib_16384_1.dblwr' '#innodb_temp' public_key.pem undo_002
root@ubuntu2204:~# mysql -V
mysql Ver 8.0.43 for Linux on x86_64 (MySQL Community Server - GPL)
root@ubuntu2204:~# systemctl status mysql
● mysql.service - MySQL Community Server
Loaded: loaded (/lib/systemd/system/mysql.service; enabled; vendor preset: enabled)
Active: active (running) since Thu 2025-10-02 19:08:40 CST; 2min 17s ago
Docs: man:mysqld(8)
http://dev.mysql.com/doc/refman/en/using-systemd.html
Main PID: 2020 (mysqld)
Status: "Server is operational"
Tasks: 37 (limit: 2176)
Memory: 362.9M
CPU: 2.309s
CGroup: /system.slice/mysql.service
└─2020 /usr/sbin/mysqld
Oct 02 19:08:40 ubuntu2204 systemd[1]: Starting MySQL Community Server...
Oct 02 19:08:40 ubuntu2204 systemd[1]: Started MySQL Community Server.
root@ubuntu2204:~# 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 - GPL
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 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: 2 min 36 sec
Threads: 2 Questions: 5 Slow queries: 0 Opens: 119 Flush tables: 3 Open tables: 38 Queries per second avg: 0.032
--------------
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| sys |
+--------------------+
4 rows in set (0.00 sec)
mysql> exit
Bye
在“Ubuntu 20.04”上安装MySQL:
"Select Version(选择版本)"为:8.0.43,“Select Operating System(选择操作系统)”为:Ubuntu Linux,"Select OS Version(选择操作系统版本)"为:根据版本选择,"Ubuntu 20.04"选择"Ubuntu Linux 20.04 (x86 , 64-bit)",然后选择”DEB Bundle“后面的”Download“,如图49所示。
图49 下载MySQL DEB包
root@ubuntu2004:~# wget https://cdn.mysql.com//Downloads/MySQL-8.0/mysql-server_8.0.43-1ubuntu20.04_amd64.deb-bundle.tar
root@ubuntu2004:~# tar xf mysql-server_8.0.43-1ubuntu20.04_amd64.deb-bundle.tar
方法1:dpkg命令安装,要按下面执行的顺序安装,否则会报错
root@ubuntu2004:~# dpkg -i mysql-community-client-plugins_8.0.43-1ubuntu20.04_amd64.deb
root@ubuntu2004:~# dpkg -i mysql-community-client-core_8.0.43-1ubuntu20.04_amd64.deb
root@ubuntu2004:~# dpkg -i mysql-common_8.0.43-1ubuntu20.04_amd64.deb
root@ubuntu2004:~# dpkg -i mysql-community-client_8.0.43-1ubuntu20.04_amd64.deb
root@ubuntu2004:~# dpkg -i libmysqlclient21_8.0.43-1ubuntu20.04_amd64.deb
root@ubuntu2004:~# dpkg -i libmysqlclient-dev_8.0.43-1ubuntu20.04_amd64.deb
root@ubuntu2004:~# dpkg -i mysql-client_8.0.43-1ubuntu20.04_amd64.deb
root@ubuntu2004:~# dpkg -i mysql-community-server-core_8.0.43-1ubuntu20.04_amd64.deb
Selecting previously unselected package mysql-community-server-core.
(Reading database ... 72420 files and directories currently installed.)
Preparing to unpack mysql-community-server-core_8.0.43-1ubuntu20.04_amd64.deb ...
Unpacking mysql-community-server-core (8.0.43-1ubuntu20.04) ...
dpkg: dependency problems prevent configuration of mysql-community-server-core:
mysql-community-server-core depends on libmecab2 (>= 0.996); however:
Package libmecab2 is not installed. # 提示,没有安装libmecab2包
mysql-community-server-core depends on libtirpc3 (>= 1.0.2); however:
Package libtirpc3 is not installed. # 提示,没有安装libtirpc3包
dpkg: error processing package mysql-community-server-core (--install):
dependency problems - leaving unconfigured
Processing triggers for libc-bin (2.31-0ubuntu9.9) ...
Processing triggers for man-db (2.9.1-1) ...
Errors were encountered while processing:
mysql-community-server-core
root@ubuntu2004:~# apt install -y libmecab2 libtirpc3
Reading package lists... Done
Building dependency tree
Reading state information... Done
You might want to run 'apt --fix-broken install' to correct these.
The following packages have unmet dependencies:
libtirpc3 : Depends: libtirpc-common (>= 1.2.5-1ubuntu0.1) but it is not going to be installed
E: Unmet dependencies. Try 'apt --fix-broken install' with no packages (or specify a solution).
# 这里会报错
# 执行下面命令安装
root@ubuntu2004:~# apt --fix-broken install
root@ubuntu2004:~# dpkg -i mysql-community-server-core_8.0.43-1ubuntu20.04_amd64.deb
root@ubuntu2004:~# dpkg -i mysql-community-server_8.0.43-1ubuntu20.04_amd64.debb
# 出现图45-47界面,按上面的提示设置。
root@ubuntu2004:~# dpkg -i mysql-server_8.0.43-1ubuntu20.04_amd64.deb
方法2:从“https://dev.mysql.com/doc/refman/8.0/en/linux-installation-debian.html”网址看到安装文档:
root@ubuntu2004:~# apt install -y libmecab2 libtirpc3
# 预先配置 MySQL 服务器软件包:
root@ubuntu2004:~# dpkg-preconfigure mysql-community-server_*.deb
# 出现图45-47界面,按上面的提示设置。
root@ubuntu2004:~# dpkg -i mysql-{common,community-client-plugins,community-client-core,community-client,client,community-server-core,community-server,server}_*.deb
继续安装MySQL:
root@ubuntu2004:~# systemctl enable --now mysql
root@ubuntu2004:~# ls /var/lib/mysql
auto.cnf ca.pem ib_buffer_pool mysql server-cert.pem
binlog.000001 client-cert.pem ibdata1 mysql.ibd server-key.pem
binlog.000002 client-key.pem ibtmp1 performance_schema sys
binlog.index '#ib_16384_0.dblwr' '#innodb_redo' private_key.pem undo_001
ca-key.pem '#ib_16384_1.dblwr' '#innodb_temp' public_key.pem undo_002
root@ubuntu2004:~# mysql -V
mysql Ver 8.0.43 for Linux on x86_64 (MySQL Community Server - GPL)
root@ubuntu2004:~# systemctl status mysql
● mysql.service - MySQL Community Server
Loaded: loaded (/lib/systemd/system/mysql.service; enabled; vendor preset: enabled)
Active: active (running) since Thu 2025-10-02 19:37:39 CST; 1min 35s ago
Docs: man:mysqld(8)
http://dev.mysql.com/doc/refman/en/using-systemd.html
Main PID: 2633 (mysqld)
Status: "Server is operational"
Tasks: 37 (limit: 2218)
Memory: 363.5M
CGroup: /system.slice/mysql.service
└─2633 /usr/sbin/mysqld
Oct 02 19:37:39 ubuntu2004 systemd[1]: Starting MySQL Community Server...
Oct 02 19:37:39 ubuntu2004 systemd[1]: Started MySQL Community Server.
root@ubuntu2004:~# 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 - GPL
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 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 57 sec
Threads: 2 Questions: 5 Slow queries: 0 Opens: 119 Flush tables: 3 Open tables: 38 Queries per second avg: 0.042
--------------
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| sys |
+--------------------+
4 rows in set (0.00 sec)
mysql> exit
Bye
在“Debian 12”上安装MySQL:
"Select Version(选择版本)"为:8.0.43,“Select Operating System(选择操作系统)”为:Debian Linux,然后选择”DEB Bundle“后面的”Download“,如图50所示。
图50 下载MySQL DEB包
root@debian12:~# wget https://cdn.mysql.com//Downloads/MySQL-8.0/mysql-server_8.0.43-1debian12_amd64.deb-bundle.tar
root@debian12:~# tar xf mysql-server_8.0.43-1debian12_amd64.deb-bundle.tar
方法1:dpkg命令安装,要按下面执行的顺序安装,否则会报错
root@debian12:~# dpkg -i mysql-community-client-plugins_8.0.43-1debian12_amd64.deb
root@debian12:~# dpkg -i mysql-community-client-core_8.0.43-1debian12_amd64.deb
root@debian12:~# dpkg -i mysql-common_8.0.43-1debian12_amd64.deb
root@debian12:~# dpkg -i mysql-community-client_8.0.43-1debian12_amd64.deb
root@debian12:~# dpkg -i libmysqlclient21_8.0.43-1debian12_amd64.debb
root@debian12:~# dpkg -i libmysqlclient-dev_8.0.43-1debian12_amd64.deb
root@debian12:~# dpkg -i mysql-client_8.0.43-1debian12_amd64.deb
root@debian12:~# dpkg -i mysql-community-server-core_8.0.43-1debian12_amd64.deb
Selecting previously unselected package mysql-community-server-core.
(Reading database ... 33672 files and directories currently installed.)
Preparing to unpack mysql-community-server-core_8.0.43-1debian12_amd64.deb ...
Unpacking mysql-community-server-core (8.0.43-1debian12) ...
dpkg: dependency problems prevent configuration of mysql-community-server-core:
mysql-community-server-core depends on libaio1 (>= 0.3.93); however:
Package libaio1 is not installed. # 提示,没有安装libaio1包
mysql-community-server-core depends on libmecab2 (>= 0.996); however:
Package libmecab2 is not installed. # 提示,没有安装libmecab2包
mysql-community-server-core depends on libnuma1 (>= 2.0.11); however:
Package libnuma1 is not installed. # 提示,没有安装libnuma1包
dpkg: error processing package mysql-community-server-core (--install):
dependency problems - leaving unconfigured
Processing triggers for libc-bin (2.36-9+deb12u10) ...
Processing triggers for man-db (2.11.2-2) ...
Errors were encountered while processing:
mysql-community-server-core
root@debian12:~# apt install -y libaio1 libmecab2 libnuma1
root@debian12:~# dpkg -i mysql-community-server-core_8.0.43-1debian12_amd64.deb
root@debian12:~# dpkg -i mysql-community-server_8.0.43-1debian12_amd64.deb
(Reading database ... 33880 files and directories currently installed.)
Preparing to unpack mysql-community-server_8.0.43-1debian12_amd64.deb ...
Unpacking mysql-community-server (8.0.43-1debian12) over (8.0.43-1debian12) ...
dpkg: dependency problems prevent configuration of mysql-community-server:
mysql-community-server depends on psmisc; however:
Package psmisc is not installed. # 提示,没有安装psmisc包
dpkg: error processing package mysql-community-server (--install):
dependency problems - leaving unconfigured
Errors were encountered while processing:
mysql-community-server
root@debian12:~# apt install -y psmisc
输入MySQL root用户密码,然后按下 Enter 键,如图51所示。
图51 输入MySQL root用户密码
在下面提示直接按下 Enter 键,如图52所示。
图52 确认提示信息
选择“Use Strong Password Encryption (RECOMMENDED)”,然后按下 Enter 键,如图53所示。
图53 选择默认身份验证插件
root@debian12:~# dpkg -i mysql-community-server_8.0.43-1debian12_amd64.deb
root@debian12:~# dpkg -i mysql-server_8.0.43-1debian12_amd64.deb
方法2:从“https://dev.mysql.com/doc/refman/8.0/en/linux-installation-debian.html”网址看到安装文档:
root@debian12:~# apt install -y libaio1 libmecab2 libnuma1 psmisc
# 预先配置 MySQL 服务器软件包:
root@debian12:~# dpkg-preconfigure mysql-community-server_*.deb
# 出现图图51-53界面,按上面的提示设置。
root@debian12:~# dpkg -i mysql-{common,community-client-plugins,community-client-core,community-client,client,community-server-core,community-server,server}_*.deb
继续安装MySQL:
root@debian12:~# systemctl enable --now mysql
root@debian12:~# ls /var/lib/mysql
auto.cnf binlog.index '#ib_16384_0.dblwr' '#innodb_redo' private_key.pem undo_001
binlog.000001 ca-key.pem '#ib_16384_1.dblwr' '#innodb_temp' public_key.pem undo_002
binlog.000002 ca.pem ib_buffer_pool mysql server-cert.pem
binlog.000003 client-cert.pem ibdata1 mysql.ibd server-key.pem
binlog.000004 client-key.pem ibtmp1 performance_schema sys
root@debian12:~# mysql -V
mysql Ver 8.0.43 for Linux on x86_64 (MySQL Community Server - GPL)
root@debian12:~# systemctl status mysql
● mysql.service - MySQL Community Server
Loaded: loaded (/lib/systemd/system/mysql.service; enabled; preset: enabled)
Active: active (running) since Wed 2025-10-01 21:58:59 CST; 54s ago
Docs: man:mysqld(8)
http://dev.mysql.com/doc/refman/en/using-systemd.html
Main PID: 1598 (mysqld)
Status: "Server is operational"
Tasks: 38 (limit: 2273)
Memory: 368.2M
CPU: 1.435s
CGroup: /system.slice/mysql.service
└─1598 /usr/sbin/mysqld
Oct 01 21:58:59 debian12 systemd[1]: Starting mysql.service - MySQL Community Server...
Oct 01 21:58:59 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 - GPL
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 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 19 sec
Threads: 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
2.2.2.2.2 MySQL 8.4
去“https://www.mysql.com/”网站下载,选择“DOWNLOADS”,如图54所示。
图54 下载MySQL DEB包
选择“MySQL Community (GPL) Downloads”,如图55所示。
图55 下载MySQL DEB包
选择“MySQL Community Server(MySQL社区服务器)”,如图56所示。
图56 下载MySQL DEB包
在“Ubuntu 24.04”上安装MySQL:
"Select Version(选择版本)"为:8.4.6 LTS,“Select Operating System(选择操作系统)”为:Ubuntu Linux,"Select OS Version(选择操作系统版本)"为:根据版本选择,"Ubuntu 24.04"选择"Ubuntu Linux 24.04 (x86 , 64-bit)",然后选择”DEB Bundle“后面的”Download“,如图57所示。
图57 下载MySQL DEB包
root@ubuntu2404:~# wget https://cdn.mysql.com//Downloads/MySQL-8.4/mysql-server_8.4.6-1ubuntu24.04_amd64.deb-bundle.tar
root@ubuntu2404:~# tar xf mysql-server_8.4.6-1ubuntu24.04_amd64.deb-bundle.tar
方法1:dpkg命令安装,要按下面执行的顺序安装,否则会报错
root@ubuntu2404:~# dpkg -i mysql-community-client-plugins_8.4.6-1ubuntu24.04_amd64.deb
root@ubuntu2404:~# dpkg -i mysql-community-client-core_8.4.6-1ubuntu24.04_amd64.deb
root@ubuntu2404:~# dpkg -i mysql-common_8.4.6-1ubuntu24.04_amd64.deb
root@ubuntu2404:~# dpkg -i mysql-community-client_8.4.6-1ubuntu24.04_amd64.deb
root@ubuntu2404:~# dpkg -i libmysqlclient24_8.4.6-1ubuntu24.04_amd64.deb
root@ubuntu2404:~# dpkg -i libmysqlclient-dev_8.4.6-1ubuntu24.04_amd64.deb
root@ubuntu2404:~# dpkg -i mysql-client_8.4.6-1ubuntu24.04_amd64.deb
root@ubuntu2404:~# dpkg -i mysql-community-server-core_8.4.6-1ubuntu24.04_amd64.deb
Selecting previously unselected package mysql-community-server-core.
(Reading database ... 87174 files and directories currently installed.)
Preparing to unpack mysql-community-server-core_8.4.6-1ubuntu24.04_amd64.deb ...
Unpacking mysql-community-server-core (8.4.6-1ubuntu24.04) ...
dpkg: dependency problems prevent configuration of mysql-community-server-core:
mysql-community-server-core depends on libmecab2 (>= 0.996); however:
Package libmecab2 is not installed. # 提示,没有安装libmecab2依赖包
dpkg: error processing package mysql-community-server-core (--install):
dependency problems - leaving unconfigured
Processing triggers for libc-bin (2.39-0ubuntu8.6) ...
Processing triggers for man-db (2.12.0-4build2) ...
Errors were encountered while processing:
mysql-community-server-core
root@ubuntu2404:~# apt install -y libmecab2
root@ubuntu2404:~# dpkg -i mysql-community-server-core_8.4.6-1ubuntu24.04_amd64.deb
root@ubuntu2404:~# dpkg -i mysql-community-server_8.4.6-1ubuntu24.04_amd64.deb
输入MySQL root用户密码,然后按下 Enter 键,如图58所示。
图58 输入MySQL root用户密码
root@ubuntu2404:~# dpkg -i mysql-server_8.4.6-1ubuntu24.04_amd64.deb
方法2:从“https://dev.mysql.com/doc/refman/8.4/en/linux-installation-debian.html”网址看到安装文档:
root@ubuntu2404:~# apt install -y libmecab2
# 预先配置 MySQL 服务器软件包:
root@ubuntu2404:~# dpkg-preconfigure mysql-community-server_*.deb
# 出现图58界面,按上面的提示设置。
root@ubuntu2404:~# dpkg -i mysql-{common,community-client-plugins,community-client-core,community-client,client,community-server-core,community-server,server}_*.deb
继续安装MySQL:
root@ubuntu2404:~# systemctl enable --now mysql
root@ubuntu2404:~# ls /var/lib/mysql
auto.cnf ca.pem ib_buffer_pool mysql public_key.pem undo_002
binlog.000001 client-cert.pem ibdata1 mysql.ibd server-cert.pem
binlog.000002 client-key.pem ibtmp1 mysql_upgrade_history server-key.pem
binlog.index '#ib_16384_0.dblwr' '#innodb_redo' performance_schema sys
ca-key.pem '#ib_16384_1.dblwr' '#innodb_temp' private_key.pem undo_001
root@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 Server
Loaded: loaded (/usr/lib/systemd/system/mysql.service; enabled; preset: enabled)
Active: active (running) since Fri 2025-10-03 11:33:03 CST; 1min 54s ago
Docs: man:mysqld(8)
http://dev.mysql.com/doc/refman/en/using-systemd.html
Main PID: 1970 (mysqld)
Status: "Server is operational"
Tasks: 34 (limit: 2210)
Memory: 420.1M (peak: 434.3M)
CPU: 2.380s
CGroup: /system.slice/mysql.service
└─1970 /usr/sbin/mysqld
Oct 03 11:33:02 ubuntu2404 systemd[1]: Starting mysql.service - MySQL Community Server...
Oct 03 11:33:03 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 - GPL
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.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: 2 min 16 sec
Threads: 2 Questions: 6 Slow queries: 0 Opens: 119 Flush tables: 3 Open tables: 38 Queries per second avg: 0.044
--------------
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| sys |
+--------------------+
4 rows in set (0.01 sec)
mysql> exit
Bye
在“Ubuntu 22.04”上安装MySQL:
"Select Version(选择版本)"为:8.4.6 LTS,“Select Operating System(选择操作系统)”为:Ubuntu Linux,"Select OS Version(选择操作系统版本)"为:根据版本选择,"Ubuntu 22.04"选择"Ubuntu Linux 22.04 (x86 , 64-bit)",然后选择”DEB Bundle“后面的”Download“,如图59所示。
图59 下载MySQL DEB包
root@ubuntu2204:~# wget https://cdn.mysql.com//Downloads/MySQL-8.4/mysql-server_8.4.6-1ubuntu22.04_amd64.deb-bundle.tar
root@ubuntu2204:~# tar xf mysql-server_8.4.6-1ubuntu22.04_amd64.deb-bundle.tar
方法1:dpkg命令安装,要按下面执行的顺序安装,否则会报错
root@ubuntu2204:~# dpkg -i mysql-community-client-plugins_8.4.6-1ubuntu22.04_amd64.deb
root@ubuntu2204:~# dpkg -i mysql-community-client-core_8.4.6-1ubuntu22.04_amd64.deb
root@ubuntu2204:~# dpkg -i mysql-common_8.4.6-1ubuntu22.04_amd64.deb
root@ubuntu2204:~# dpkg -i mysql-community-client_8.4.6-1ubuntu22.04_amd64.deb
root@ubuntu2204:~# dpkg -i libmysqlclient24_8.4.6-1ubuntu22.04_amd64.deb
root@ubuntu2204:~# dpkg -i libmysqlclient-dev_8.4.6-1ubuntu22.04_amd64.deb
root@ubuntu2204:~# dpkg -i mysql-client_8.4.6-1ubuntu22.04_amd64.deb
root@ubuntu2204:~# dpkg -i mysql-community-server-core_8.4.6-1ubuntu22.04_amd64.deb
Selecting previously unselected package mysql-community-server-core.
(Reading database ... 74797 files and directories currently installed.)
Preparing to unpack mysql-community-server-core_8.4.6-1ubuntu22.04_amd64.deb ...
Unpacking mysql-community-server-core (8.4.6-1ubuntu22.04) ...
dpkg: dependency problems prevent configuration of mysql-community-server-core:
mysql-community-server-core depends on libmecab2 (>= 0.996); however:
Package libmecab2 is not installed. # 提示,没有安装libmecab2依赖包
dpkg: error processing package mysql-community-server-core (--install):
dependency problems - leaving unconfigured
Processing triggers for libc-bin (2.35-0ubuntu3.8) ...
Processing triggers for man-db (2.10.2-1) ...
Errors were encountered while processing:
mysql-community-server-core
root@ubuntu2404:~# apt install -y libmecab2
root@ubuntu2204:~# dpkg -i mysql-community-server-core_8.4.6-1ubuntu22.04_amd64.deb
root@ubuntu2204:~# dpkg -i mysql-community-server_8.4.6-1ubuntu22.04_amd64.deb
# 出现图58界面,按上面的提示设置。
root@ubuntu2204:~# dpkg -i mysql-server_8.4.6-1ubuntu22.04_amd64.deb
方法2:从“https://dev.mysql.com/doc/refman/8.4/en/linux-installation-debian.html”网址看到安装文档:
root@ubuntu2204:~# apt install -y libmecab2
# 预先配置 MySQL 服务器软件包:
root@ubuntu2204:~# dpkg-preconfigure mysql-community-server_*.deb
# 出现图58界面,按上面的提示设置。
root@ubuntu2204:~# dpkg -i mysql-{common,community-client-plugins,community-client-core,community-client,client,community-server-core,community-server,server}_*.deb
继续安装MySQL:
root@ubuntu2204:~# systemctl enable --now mysql
root@ubuntu2204:~# ls /var/lib/mysql
auto.cnf ca.pem ib_buffer_pool mysql public_key.pem undo_002
binlog.000001 client-cert.pem ibdata1 mysql.ibd server-cert.pem
binlog.000002 client-key.pem ibtmp1 mysql_upgrade_history server-key.pem
binlog.index '#ib_16384_0.dblwr' '#innodb_redo' performance_schema sys
ca-key.pem '#ib_16384_1.dblwr' '#innodb_temp' private_key.pem undo_001
root@ubuntu2204:~# mysql -V
mysql Ver 8.4.6 for Linux on x86_64 (MySQL Community Server - GPL)
root@ubuntu2204:~# systemctl status mysql
● mysql.service - MySQL Community Server
Loaded: loaded (/lib/systemd/system/mysql.service; enabled; vendor preset: enabled)
Active: active (running) since Fri 2025-10-03 11:57:11 CST; 1min 37s ago
Docs: man:mysqld(8)
http://dev.mysql.com/doc/refman/en/using-systemd.html
Main PID: 2865 (mysqld)
Status: "Server is operational"
Tasks: 34 (limit: 2176)
Memory: 420.8M
CPU: 1.912s
CGroup: /system.slice/mysql.service
└─2865 /usr/sbin/mysqld
Oct 03 11:57:11 ubuntu2204 systemd[1]: Starting MySQL Community Server...
Oct 03 11:57:11 ubuntu2204 systemd[1]: Started MySQL Community Server.
root@ubuntu2204:~# 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 - GPL
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.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: 1 min 56 sec
Threads: 2 Questions: 6 Slow queries: 0 Opens: 119 Flush tables: 3 Open tables: 38 Queries per second avg: 0.051
--------------
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| sys |
+--------------------+
4 rows in set (0.01 sec)
mysql> exit
Bye
在“Debian 12”上安装MySQL:
"Select Version(选择版本)"为:8.4.6 LTS,“Select Operating System(选择操作系统)”为:Debian Linux,然后选择”DEB Bundle“后面的”Download“,如图60所示。
图60 下载MySQL DEB包
root@debian12:~# wget https://cdn.mysql.com//Downloads/MySQL-8.4/mysql-server_8.4.6-1debian12_amd64.deb-bundle.tar
root@debian12:~# tar xf mysql-server_8.4.6-1debian12_amd64.deb-bundle.tar
方法1:dpkg命令安装,要按下面执行的顺序安装,否则会报错
root@debian12:~# dpkg -i mysql-community-client-plugins_8.4.6-1debian12_amd64.deb
root@debian12:~# dpkg -i mysql-community-client-core_8.4.6-1debian12_amd64.deb
root@debian12:~# dpkg -i mysql-common_8.4.6-1debian12_amd64.deb
root@debian12:~# dpkg -i mysql-community-client_8.4.6-1debian12_amd64.deb
root@debian12:~# dpkg -i libmysqlclient24_8.4.6-1debian12_amd64.deb
root@debian12:~# dpkg -i libmysqlclient-dev_8.4.6-1debian12_amd64.deb
root@debian12:~# dpkg -i mysql-client_8.4.6-1debian12_amd64.deb
root@debian12:~# dpkg -i mysql-community-server-core_8.4.6-1debian12_amd64.deb
Selecting previously unselected package mysql-community-server-core.
(Reading database ... 33670 files and directories currently installed.)
Preparing to unpack mysql-community-server-core_8.4.6-1debian12_amd64.deb ...
Unpacking mysql-community-server-core (8.4.6-1debian12) ...
dpkg: dependency problems prevent configuration of mysql-community-server-core:
mysql-community-server-core depends on libaio1 (>= 0.3.93); however:
Package libaio1 is not installed. # 提示,没有安装libaio1依赖包
mysql-community-server-core depends on libmecab2 (>= 0.996); however:
Package libmecab2 is not installed. # 提示,没有安装libmecab2依赖包
mysql-community-server-core depends on libnuma1 (>= 2.0.11); however:
Package libnuma1 is not installed. # 提示,没有安装libnuma1依赖包
dpkg: error processing package mysql-community-server-core (--install):
dependency problems - leaving unconfigured
Processing triggers for libc-bin (2.36-9+deb12u10) ...
Processing triggers for man-db (2.11.2-2) ...
Errors were encountered while processing:
mysql-community-server-core
root@debian12:~# apt install -y libaio1 libmecab2 libnuma1
root@debian12:~# dpkg -i mysql-community-server-core_8.4.6-1debian12_amd64.deb
root@debian12:~# dpkg -i mysql-community-server_8.4.6-1debian12_amd64.deb
Selecting previously unselected package mysql-community-server.
(Reading database ... 33934 files and directories currently installed.)
Preparing to unpack mysql-community-server_8.4.6-1debian12_amd64.deb ...
adduser: Warning: The home dir /var/lib/mysql you specified can't be accessed: No such file or directory
Unpacking mysql-community-server (8.4.6-1debian12) ...
dpkg: dependency problems prevent configuration of mysql-community-server:
mysql-community-server depends on psmisc; however:
Package psmisc is not installed. # 提示,没有安装psmisc依赖包
dpkg: error processing package mysql-community-server (--install):
dependency problems - leaving unconfigured
Errors were encountered while processing:
mysql-community-server
root@debian12:~# apt install -y psmisc
输入MySQL root用户密码,然后按下 Enter 键,如图61所示。
图61 输入MySQL root用户密码
root@debian12:~# dpkg -i mysql-community-server_8.4.6-1debian12_amd64.deb
root@debian12:~# dpkg -i mysql-server_8.4.6-1debian12_amd64.deb
方法2:从“https://dev.mysql.com/doc/refman/8.4/en/linux-installation-debian.html”网址看到安装文档:
root@debian12:~# apt install -y libaio1 libmecab2 libnuma1 psmisc
# 预先配置 MySQL 服务器软件包:
root@debian12:~# dpkg-preconfigure mysql-community-server_*.deb
# 出现图61界面,按上面的提示设置。
root@debian12:~# dpkg -i mysql-{common,community-client-plugins,community-client-core,community-client,client,community-server-core,community-server,server}_*.deb
继续安装MySQL:
root@debian12:~# systemctl enable --now mysql
root@debian12:~# ls /var/lib/mysql
auto.cnf binlog.index '#ib_16384_0.dblwr' '#innodb_redo' performance_schema sys
binlog.000001 ca-key.pem '#ib_16384_1.dblwr' '#innodb_temp' private_key.pem undo_001
binlog.000002 ca.pem ib_buffer_pool mysql public_key.pem undo_002
binlog.000003 client-cert.pem ibdata1 mysql.ibd server-cert.pem
binlog.000004 client-key.pem ibtmp1 mysql_upgrade_history server-key.pem
root@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 Server
Loaded: loaded (/lib/systemd/system/mysql.service; enabled; preset: enabled)
Active: active (running) since Fri 2025-10-03 12:42:24 CST; 1min 47s ago
Docs: man:mysqld(8)
http://dev.mysql.com/doc/refman/en/using-systemd.html
Main PID: 1544 (mysqld)
Status: "Server is operational"
Tasks: 34 (limit: 2273)
Memory: 428.0M
CPU: 2.267s
CGroup: /system.slice/mysql.service
└─1544 /usr/sbin/mysqld
Oct 03 12:42:23 debian12 systemd[1]: Starting mysql.service - MySQL Community Server...
Oct 03 12:42:24 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 - GPL
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.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: 2 min 6 sec
Threads: 2 Questions: 6 Slow queries: 0 Opens: 119 Flush tables: 3 Open tables: 38 Queries per second avg: 0.047
--------------
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| sys |
+--------------------+
4 rows in set (0.00 sec)
mysql> exit
Bye