在线YUM仓库
打开MySQL官网(MySQL)
点击【Downloads】进入下载界面
点击【MySQL Community(GPL) Downloads】进入社区版下载界面
点击【MySQL Yum Repository】进入在线仓库安装界面
点击【Download】下载
点击【No,thanks,just start my download】直接下载
开启虚拟机,复制文件下载路径,使用wget命令直接下载,传到linux操作系统中
[root@jyh ~]# wget https://repo.mysql.com//mysql84-community-release-el9-1.noarch.rpm
--2025-01-06 20:48:45-- https://repo.mysql.com//mysql84-community-release-el9-1.noarch.rpm
Resolving repo.mysql.com (repo.mysql.com)... 118.215.12.119, 2600:1417:7800:28c::1d68, 2600:1417:7800:280::1d68
Connecting to repo.mysql.com (repo.mysql.com)|118.215.12.119|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 13139 (13K) [application/x-redhat-package-manager]
Saving to: ‘mysql84-community-release-el9-1.noarch.rpm’mysql84-community-r 100%[==================>] 12.83K --.-KB/s in 0s2025-01-06 20:48:46 (147 MB/s) - ‘mysql84-community-release-el9-1.noarch.rpm’ saved [13139/13139]
使用rpm命令直接使用链接进行安装
[root@jyh ~]# rpm -i https://repo.mysql.com//mysql84-community-release-el9-1.noarch.rpm
warning: /var/tmp/rpm-tmp.8DBkAF: Header V4 RSA/SHA256 Signature, key ID a8d3785c: NOKEY
[root@jyh ~]# mount /dev/sr0 /mnt
mount: /mnt: WARNING: source write-protected, mounted read-only.[root@jyh ~]# dnf repolist
Updating Subscription Management repositories.
Unable to read consumer identityThis system is not registered with an entitlement server. You can use subscription-manager to register.repo id repo name
appstream appstream
baseos baseos
mysql-8.4-lts-community MySQL 8.4 LTS Community Server
mysql-connectors-community MySQL Connectors Community
mysql-tools-8.4-lts-community MySQL Tools 8.4 LTS Community
安装完成后,可以看到新增的三个仓库
通过仓库安装MySQL数据库
[root@jyh ~]# dnf install mysql-server
Updating Subscription Management repositories.
Unable to read consumer identityThis system is not registered with an entitlement server. You can use subscription-manager to register.baseos 195 MB/s | 1.7 MB 00:00
appstream 195 MB/s | 6.1 MB 00:00
Dependencies resolved.
===============================================================================Package Arch Version Repository Size
===============================================================================
Installing:mysql-community-server x86_64 8.4.3-1.el9 mysql-8.4-lts-community 50 M
Installing dependencies:mysql-community-client x86_64 8.4.3-1.el9 mysql-8.4-lts-community 3.1 Mmysql-community-client-pluginsx86_64 8.4.3-1.el9 mysql-8.4-lts-community 1.5 Mmysql-community-common x86_64 8.4.3-1.el9 mysql-8.4-lts-community 575 kmysql-community-icu-data-filesx86_64 8.4.3-1.el9 mysql-8.4-lts-community 2.3 Mmysql-community-libs x86_64 8.4.3-1.el9 mysql-8.4-lts-community 1.5 MTransaction Summary
===============================================================================
Install 6 PackagesTotal download size: 59 M
Installed size: 330 M
Is this ok [y/N]: y
Downloading Packages:
(1/6): mysql-community-common-8.4.3-1.el9.x86_ 165 kB/s | 575 kB 00:03
(2/6): mysql-community-client-plugins-8.4.3-1. 159 kB/s | 1.5 MB 00:09
(3/6): mysql-community-icu-data-files-8.4.3-1. 195 kB/s | 2.3 MB 00:11
(4/6): mysql-community-client-8.4.3-1.el9.x86_ 175 kB/s | 3.1 MB 00:18
(5/6): mysql-community-libs-8.4.3-1.el9.x86_64 161 kB/s | 1.5 MB 00:09
(6/6): mysql-community-server-8.4.3-1.el9.x86_ 471 kB/s | 50 MB 01:48
-------------------------------------------------------------------------------
Total 486 kB/s | 59 MB 02:03
MySQL 8.4 LTS Community Server 3.0 MB/s | 3.1 kB 00:00
Importing GPG key 0xA8D3785C:Userid : "MySQL Release Engineering <mysql-build@oss.oracle.com>"Fingerprint: BCA4 3417 C3B4 85DD 128E C6D4 B7B3 B788 A8D3 785CFrom : /etc/pki/rpm-gpg/RPM-GPG-KEY-mysql-2023
Is this ok [y/N]: y
Key imported successfully
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transactionPreparing : 1/1Installing : mysql-community-common-8.4.3-1.el9.x86_64 1/6Installing : mysql-community-client-plugins-8.4.3-1.el9.x86_64 2/6Installing : mysql-community-libs-8.4.3-1.el9.x86_64 3/6Running scriptlet: mysql-community-libs-8.4.3-1.el9.x86_64 3/6Installing : mysql-community-client-8.4.3-1.el9.x86_64 4/6Installing : mysql-community-icu-data-files-8.4.3-1.el9.x86_64 5/6Running scriptlet: mysql-community-server-8.4.3-1.el9.x86_64 6/6Installing : mysql-community-server-8.4.3-1.el9.x86_64 6/6Running scriptlet: mysql-community-server-8.4.3-1.el9.x86_64 6/6Verifying : mysql-community-client-8.4.3-1.el9.x86_64 1/6Verifying : mysql-community-client-plugins-8.4.3-1.el9.x86_64 2/6Verifying : mysql-community-common-8.4.3-1.el9.x86_64 3/6Verifying : mysql-community-icu-data-files-8.4.3-1.el9.x86_64 4/6Verifying : mysql-community-libs-8.4.3-1.el9.x86_64 5/6Verifying : mysql-community-server-8.4.3-1.el9.x86_64 6/6
Installed products updated.Installed:mysql-community-client-8.4.3-1.el9.x86_64mysql-community-client-plugins-8.4.3-1.el9.x86_64mysql-community-common-8.4.3-1.el9.x86_64mysql-community-icu-data-files-8.4.3-1.el9.x86_64mysql-community-libs-8.4.3-1.el9.x86_64mysql-community-server-8.4.3-1.el9.x86_64Complete!
查看临时密码并进入
[root@jyh ~]# grep password /var/log/mysqld.log
2025-01-06T13:47:17.010009Z 6 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: 6!l&X(sUDChh
[root@jyh ~]# mysql -uroot -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 9
Server version: 8.4.3Copyright (c) 2000, 2024, 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> show databases;
ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement.
mysql> alter user 'root'@'localhost' identified by '#OPENlab123';
Query OK, 0 rows affected (0.00 sec)mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| sys |
+--------------------+
4 rows in set (0.00 sec)
删除清理
[root@jyh ~]# dnf remove mysql-server -y
[root@jyh ~]# rm -rf /var/lib/mysql
[root@jyh ~]# rm -rf /var/log/mysqld.log
[root@jyh ~]# userdel -r mysql
userdel: mysql mail spool (/var/spool/mail/mysql) not found
userdel: mysql home directory (/var/lib/mysql) not found
二进制本地
点击【MySQL Community Server】进入下载页面
三个下拉框选择,点击【Download】下载
点击【No,thanks,just start my download】直接下载
使用wget命令直接下载
[root@jyh ~]# wget https://cdn.mysql.com//Downloads/MySQL-8.4/mysql-8.4.3-1.el9.x86_64.rpm-bundle.tar
--2025-01-06 22:40:46-- https://cdn.mysql.com//Downloads/MySQL-8.4/mysql-8.4.3-1.el9.x86_64.rpm-bundle.tar
Resolving cdn.mysql.com (cdn.mysql.com)... 118.215.12.119, 2600:140e:6:da4::1d68, 2600:140e:6:daf::1d68
Connecting to cdn.mysql.com (cdn.mysql.com)|118.215.12.119|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 926351360 (883M) [application/x-tar]
Saving to: ‘mysql-8.4.3-1.el9.x86_64.rpm-bundle.tar’mysql-8.4.3-1.el9.x 100%[==================>] 883.44M 4.72MB/s in 3m 0s2025-01-06 22:43:46 (4.91 MB/s) - ‘mysql-8.4.3-1.el9.x86_64.rpm-bundle.tar’ saved [926351360/926351360]
对tar包进行解压
[root@jyh mysql]# tar xf mysql-8.4.3-1.el9.x86_64.rpm-bundle.tar
[root@jyh mysql]# ll
total 1809300
-rw-r--r--. 1 root root 926351360 Sep 18 23:32 mysql-8.4.3-1.el9.x86_64.rpm-bundle.tar
-rw-r--r--. 1 7155 31415 3227147 Sep 18 22:56 mysql-community-client-8.4.3-1.el9.x86_64.rpm
-rw-r--r--. 1 7155 31415 26074383 Sep 18 22:56 mysql-community-client-debuginfo-8.4.3-1.el9.x86_64.rpm
-rw-r--r--. 1 7155 31415 1553818 Sep 18 22:56 mysql-community-client-plugins-8.4.3-1.el9.x86_64.rpm
-rw-r--r--. 1 7155 31415 2886408 Sep 18 22:56 mysql-community-client-plugins-debuginfo-8.4.3-1.el9.x86_64.rpm
-rw-r--r--. 1 7155 31415 588325 Sep 18 22:56 mysql-community-common-8.4.3-1.el9.x86_64.rpm
-rw-r--r--. 1 7155 31415 5641071 Sep 18 22:57 mysql-community-debuginfo-8.4.3-1.el9.x86_64.rpm
-rw-r--r--. 1 7155 31415 18136250 Sep 18 22:57 mysql-community-debugsource-8.4.3-1.el9.x86_64.rpm
-rw-r--r--. 1 7155 31415 7855927 Sep 18 22:57 mysql-community-devel-8.4.3-1.el9.x86_64.rpm
-rw-r--r--. 1 7155 31415 2382047 Sep 18 22:57 mysql-community-icu-data-files-8.4.3-1.el9.x86_64.rpm
-rw-r--r--. 1 7155 31415 1552358 Sep 18 22:57 mysql-community-libs-8.4.3-1.el9.x86_64.rpm
-rw-r--r--. 1 7155 31415 1512682 Sep 18 22:57 mysql-community-libs-compat-8.4.3-1.el9.x86_64.rpm
-rw-r--r--. 1 7155 31415 2575177 Sep 18 22:57 mysql-community-libs-compat-debuginfo-8.4.3-1.el9.x86_64.rpm
-rw-r--r--. 1 7155 31415 2699803 Sep 18 22:57 mysql-community-libs-debuginfo-8.4.3-1.el9.x86_64.rpm
-rw-r--r--. 1 7155 31415 52294643 Sep 18 22:58 mysql-community-server-8.4.3-1.el9.x86_64.rpm
-rw-r--r--. 1 7155 31415 24998397 Sep 18 22:58 mysql-community-server-debug-8.4.3-1.el9.x86_64.rpm
-rw-r--r--. 1 7155 31415 161234615 Sep 18 22:58 mysql-community-server-debug-debuginfo-8.4.3-1.el9.x86_64.rpm
-rw-r--r--. 1 7155 31415 200794217 Sep 18 22:58 mysql-community-server-debuginfo-8.4.3-1.el9.x86_64.rpm
-rw-r--r--. 1 7155 31415 386301167 Sep 18 22:59 mysql-community-test-8.4.3-1.el9.x86_64.rpm
-rw-r--r--. 1 7155 31415 24027239 Sep 18 23:00 mysql-community-test-debuginfo-8.4.3-1.el9.x86_64.rpm
使用rpm命令进行安装
[root@jyh mysql]# rpm -i mysql-community-server-8.4.3-1.el9.x86_64.rpm mysql-community-client-8.4.3-1.el9.x86_64.rpm mysql-community-client-plugins-8.4.3-1.el9.x86_64.rpm mysql-community-common-8.4.3-1.el9.x86_64.rpm mysql-community-icu-data-files-8.4.3-1.el9.x86_64.rpm mysql-community-libs-8.4.3-1.el9.x86_64.rpmpackage mysql-community-common-8.4.3-1.el9.x86_64 is already installedpackage mysql-community-client-plugins-8.4.3-1.el9.x86_64 is already installedpackage mysql-community-libs-8.4.3-1.el9.x86_64 is already installedpackage mysql-community-client-8.4.3-1.el9.x86_64 is already installedpackage mysql-community-icu-data-files-8.4.3-1.el9.x86_64 is already installedpackage mysql-community-server-8.4.3-1.el9.x86_64 is already installed
[root@jyh mysql]# cd
[root@jyh ~]# rpm -qa | grep mysql
mysql84-community-release-el9-1.noarch
mysql-community-common-8.4.3-1.el9.x86_64
mysql-community-client-plugins-8.4.3-1.el9.x86_64
mysql-community-libs-8.4.3-1.el9.x86_64
mysql-community-client-8.4.3-1.el9.x86_64
mysql-community-icu-data-files-8.4.3-1.el9.x86_64
mysql-community-server-8.4.3-1.el9.x86_64
或者用dnf命令进行安装
[root@jyh ~]# dnf localinstall mysql-community-server-8.4.3
1.el9.x86_64.rpm
Updating Subscription Management repositories.Unable to read consumer identityThis system is not registered with an entitlement server. You can use "rhc"
or "subscription-manager" to register.Last metadata expiration check: 0:04:32 ago on Mon 30 Dec 2024 12:46:44 PM
CST.Dependencies resolved.=================================================================================================================================================Package Architecture
Version Repository Size=================================================================================================================================================Installing:mysql-community-server x86_64
8.4.3-1.el9 @commandline 50 MInstalling dependencies:mysql-community-client x86_64
8.4.3-1.el9 mysql-8.4-lts-community 3.1 Mmysql-community-client-plugins x86_64
8.4.3-1.el9 mysql-8.4-lts-community 1.5 Mmysql-community-common x86_64
8.4.3-1.el9 mysql-8.4-lts-community 575 kmysql-community-icu-data-files x86_64
8.4.3-1.el9 mysql-8.4-lts-community 2.3 Mmysql-community-libs x86_64
8.4.3-1.el9 mysql-8.4-lts-community 1.5 MTransaction Summary=================================================================================================================================================Install 6 PackagesTotal size: 59 MTotal download size: 8.9 MInstalled size: 330 MIs this ok [y/N]: yDownloading Packages:(1/5): mysql-community-common-8.4.3-1.el9.x86_64.rpm 1.6 MB/s | 575 kB 00:00
(2/5): mysql-community-client-plugins-8.4.3-1.el9.x86_64.rpm 4.0 MB/s | 1.5 MB 00:00
(3/5): mysql-community-client-8.4.3-1.el9.x86_64.rpm 6.2 MB/s | 3.1 MB 00:00
(4/5): mysql-community-libs-8.4.3-1.el9.x86_64.rpm 11 MB/s | 1.5 MB 00:00
(5/5): mysql-community-icu-data-files-8.4.3-1.el9.x86_64.rpm 9.6 MB/s | 2.3 MB 00:00
------------------------------------------------------------------------------------------------------------------------------------------------
Total 15 MB/s | 8.9 MB 00:00
Running transaction checkTransaction check succeeded.Running transaction testTransaction test succeeded.Running transactionPreparing : 1/1 Installing : mysql-community-common-8.4.3-1.el9.x86_64 1/6 Installing : mysql-community-client-plugins-8.4.3-1.el9.x86_64 2/6 Installing : mysql-community-libs-8.4.3-1.el9.x86_64 3/6 Running scriptlet: mysql-community-libs-8.4.3-1.el9.x86_64 3/6 Installing : mysql-community-client-8.4.3-1.el9.x86_64 4/6 Installing : mysql-community-icu-data-files-8.4.3-1.el9.x86_64 5/6 Running scriptlet: mysql-community-server-8.4.3-1.el9.x86_64 6/6 Installing : mysql-community-server-8.4.3-1.el9.x86_64 6/6 Running scriptlet: mysql-community-server-8.4.3-1.el9.x86_64 6/6 Verifying : mysql-community-client-8.4.3-1.el9.x86_64 1/6 Verifying : mysql-community-client-plugins-8.4.3-1.el9.x86_64 2/6 Verifying : mysql-community-common-8.4.3-1.el9.x86_64 3/6 Verifying : mysql-community-icu-data-files-8.4.3-1.el9.x86_64 4/6 Verifying : mysql-community-libs-8.4.3-1.el9.x86_64 5/6 Verifying : mysql-community-server-8.4.3-1.el9.x86_64 6/6
Installed products updated.Installed:mysql-community-client-8.4.3-1.el9.x86_64 mysql-community-client
plugins-8.4.3-1.el9.x86_64 mysql-community-common-8.4.3-1.el9.x86_64mysql-community-icu-data-files-8.4.3-1.el9.x86_64 mysql-community-libs
8.4.3-1.el9.x86_64 mysql-community-server-8.4.3-1.el9.x86_64Complete!
查看临时密码并进入
[root@jyh ~]# grep password /var/log/mysqld.log
2025-01-06T13:47:17.010009Z 6 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: 6!l&X(sUDChh
[root@jyh ~]# mysql -uroot -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 11
Server version: 8.4.3Copyright (c) 2000, 2024, 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> show databases;
ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement.
mysql> alter user 'root'@'localhost' identified by '#OPENlab123';
Query OK, 0 rows affected (0.03 sec)mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| sys |
+--------------------+
4 rows in set (0.02 sec)
删除清理
[root@jyh ~]# dnf remove mysql-server -y
[root@jyh ~]# rm -rf /var/lib/mysql
[root@jyh ~]# rm -rf /var/log/mysqld.log
[root@jyh ~]# userdel -r mysql
userdel: mysql mail spool (/var/spool/mail/mysql) not found
userdel: mysql home directory (/var/lib/mysql) not found
容器平台docker
删除之前的容器安装
[root@jyh ~]# dnf remove docker \
配置容器软件仓库
[root@jyh ~]# dnf -y install dnf-plugins-core
Updating Subscription Management repositories.
Unable to read consumer identityThis system is not registered with an entitlement server. You can use subscription-manager to register.Last metadata expiration check: 1:52:45 ago on Mon 06 Jan 2025 09:42:16 PM CST.
Package dnf-plugins-core-4.1.0-3.el9.noarch is already installed.
Dependencies resolved.
Nothing to do.
Complete!
[root@jyh ~]# dnf config-manager --add-repo https://download.docker.com/linux/rhel/docker-ce.repo
Updating Subscription Management repositories.
Unable to read consumer identityThis system is not registered with an entitlement server. You can use subscription-manager to register.Adding repo from: https://download.docker.com/linux/rhel/docker-ce.repo
安装Docker相关软件
[root@jyh ~]# dnf install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
Updating Subscription Management repositories.
Unable to read consumer identityThis system is not registered with an entitlement server. You can use "rhc" or "subscription-manager" to register.Last metadata expiration check: 1:01:28 ago on Tue 07 Jan 2025 04:37:28 PM CST.
Dependencies resolved.
============================================================================
=====================================================================
Package Architecture
Version Repository Size
============================================================================
=====================================================================
Installing:
containerd.io x86_64
1.7.24-3.1.el9 docker-ce-stable 43 M
docker-buildx-plugin x86_64
0.19.3-1.el9 docker-ce-stable 14 M
docker-ce x86_64
3:27.4.1-1.el9 docker-ce-stable 27 M
docker-ce-cli x86_64
1:27.4.1-1.el9 docker-ce-stable 8.0 M
docker-compose-plugin x86_64
2.32.1-1.el9 docker-ce-stable 14 M
Installing dependencies:
container-selinux noarch
3:2.232.1-1.el9 appstream 60 k
fuse-overlayfs x86_64 1.14-
1.el9 appstream 69 k
libslirp x86_64 4.4.0-
8.el9 appstream 70 k
slirp4netns x86_64 1.3.1-
1.el9 appstream 49 k
stalling weak dependencies:
docker-ce-rootless-extras x86_64
27.4.1-1.el9 docker-ce-stable 4.4 M
Transaction Summary
============================================================================
=====================================================================
Install 10 Packages
Total size: 110 M
Installed size: 430 M
Is this ok [y/N]: y
Downloading Packages:
[SKIPPED] containerd.io-1.7.24-3.1.el9.x86_64.rpm: Already downloaded
[SKIPPED] docker-buildx-plugin-0.19.3-1.el9.x86_64.rpm: Already downloaded
[SKIPPED] docker-ce-27.4.1-1.el9.x86_64.rpm: Already downloaded
[SKIPPED] docker-ce-cli-27.4.1-1.el9.x86_64.rpm: Already downloaded
[SKIPPED] docker-ce-rootless-extras-27.4.1-1.el9.x86_64.rpm: Already
downloaded
[SKIPPED] docker-compose-plugin-2.32.1-1.el9.x86_64.rpm: Already downloaded
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
Preparing :
1/1
Running scriptlet: container-selinux-3:2.232.1-1.el9.noarch
1/10
Installing : container-selinux-3:2.232.1-1.el9.noarch
1/10
Running scriptlet: container-selinux-3:2.232.1-1.el9.noarch
1/10
Installing : docker-compose-plugin-2.32.1-1.el9.x86_64
2/10
Running scriptlet: docker-compose-plugin-2.32.1-1.el9.x86_64
2/10
Installing : containerd.io-1.7.24-3.1.el9.x86_64
3/10
Running scriptlet: containerd.io-1.7.24-3.1.el9.x86_64
3/10
Installing : libslirp-4.4.0-8.el9.x86_64
4/10
Installing : slirp4netns-1.3.1-1.el9.x86_64
5/10
Installing : fuse-overlayfs-1.14-1.el9.x86_64
6/10
Running scriptlet: fuse-overlayfs-1.14-1.el9.x86_64
6/10
Installing : docker-buildx-plugin-0.19.3-1.el9.x86_64
7/10
Running scriptlet: docker-buildx-plugin-0.19.3-1.el9.x86_64
7/10
Installing : docker-ce-cli-1:27.4.1-1.el9.x86_64
8/10
Running scriptlet: docker-ce-cli-1:27.4.1-1.el9.x86_64
8/10
Installing : docker-ce-rootless-extras-27.4.1-1.el9.x86_64
9/10
Running scriptlet: docker-ce-rootless-extras-27.4.1-1.el9.x86_64
9/10
Installing : docker-ce-3:27.4.1-1.el9.x86_64
10/10
Running scriptlet: docker-ce-3:27.4.1-1.el9.x86_64
10/10
Running scriptlet: container-selinux-3:2.232.1-1.el9.noarch
10/10
Running scriptlet: docker-ce-3:27.4.1-1.el9.x86_64
10/10
Verifying : containerd.io-1.7.24-3.1.el9.x86_64
1/10
Verifying : docker-buildx-plugin-0.19.3-1.el9.x86_64
2/10
Verifying : docker-ce-3:27.4.1-1.el9.x86_64
3/10
Verifying : docker-ce-cli-1:27.4.1-1.el9.x86_64
4/10
Verifying : docker-ce-rootless-extras-27.4.1-1.el9.x86_64
5/10
Verifying : docker-compose-plugin-2.32.1-1.el9.x86_64
6/10
Verifying : container-selinux-3:2.232.1-1.el9.noarch
7/10
Verifying : fuse-overlayfs-1.14-1.el9.x86_64
8/10
Verifying : libslirp-4.4.0-8.el9.x86_64
9/10
Verifying : slirp4netns-1.3.1-1.el9.x86_64
10/10
Installed products updated.
Installed:
container-selinux-3:2.232.1-1.el9.noarch containerd.io-1.7.24-
3.1.el9.x86_64 docker-buildx-plugin-0.19.3-1.el9.x86_64
docker-ce-3:27.4.1-1.el9.x86_64 docker-ce-cli-1:27.4.1-
1.el9.x86_64 docker-ce-rootless-extras-27.4.1-1.el9.x86_64
docker-compose-plugin-2.32.1-1.el9.x86_64 fuse-overlayfs-1.14-
1.el9.x86_64 libslirp-4.4.0-8.el9.x86_64
slirp4netns-1.3.1-1.el9.x86_64complete!
启动Docker服务
[root@jyh ~]# systemctl enable --now docker
Created symlink /etc/systemd/system/multi-user.target.wants/docker.service →
/usr/lib/systemd/system/docker.service.
拉取MySQL镜像
[root@jyh ~]# docker search mysql
NAME DESCRIPTION STARS
OFFICIAL
mysql MySQL is a widely used, open-source relation… 15562bitnami/mysql Bitnami container image for MySQL 122
circleci/mysql MySQL is a widely used, open-source relation… 30
cimg/mysql 3
bitnamicharts/mysql Bitnami Helm chart for MySQL 0
ubuntu/mysql MySQL open source fast, stable, multi-thread… 66
rapidfort/mysql RapidFort optimized, hardened image for MySQL 26
elestio/mysql Mysql, verified and packaged by Elestio 1
google/mysql MySQL server for Google Compute Engine 25
docksal/mysql MySQL service images for Docksal - https://d… 0
alpine/mysql mysql client 3
mysql/mysql-server Optimized MySQL Server Docker images. Create… 1024
jumpserver/mysql 1
datajoint/mysql MySQL image pre-configured to work smoothly … 2
ddev/mysql ARM64 base images for ddev-dbserver-mysql-8.… 1
mysql/mysql-router MySQL Router provides transparent routing be… 28
mirantis/mysql 0
ilios/mysql Mysql configured for running Ilios 1
corpusops/mysql https://github.com/corpusops/docker-images/ 0
mysql/mysql-cluster Experimental MySQL Cluster Docker images. Cr… 100
javanile/mysql MySQL for development 0
vulhub/mysql 1
mysql/mysql-operator MySQL Operator for Kubernetes 1
vitess/mysql Lightweight image to run MySQL with Vitess 1
nasqueron/mysql 1
[root@jyh ~]# docker pull mysql:8.4.3
8.4.3: Pulling from library/mysql
2c0a233485c3: Pull complete
6f5cca38a221: Pull complete
d7c84b66ede0: Pull complete
299f6f88c6cf: Pull complete
d39eae8f9927: Pull complete
ec0557361569: Pull complete
f6d0f80cb1be: Pull complete
d496030b710c: Pull complete
4d755d8c89d1: Pull complete
699d8e3dc44b: Pull complete
Digest:
sha256:106d5197fd8e4892980469ad42eb20f7a336bd81509aae4ee175d852f5cc4565
Status: Downloaded newer image for mysql:8.4.3
docker.io/library/mysql:8.4.3
[root@jyh ~]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
mysql 8.4.3 3818a28b4a67 2 months ago 594MB
启动容器
[root@jyh ~]# docker run --name mysqltest -e MYSQL_ROOT_PASSWORD=123456 -d
mysql:8.4.3
74d9d3e6cd837c7bb1fda3b97083f743e5bba58119ce6b3d68374e9806f23f99
查看并测试
[root@jyh ~]# docker ps
CONTAINER ID IMAGE
STATUS
74d9d3e6cd83
seconds
PORTS
mysql:8.4.3
COMMAND
NAMES
"docker-entrypoint.s…"
3306/tcp, 33060/tcp mysqltest
CREATED
[root@jyh ~]# docker exec -it mysqltest /bin/bash
bash-5.1# mysql -uroot -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 8
Server version: 8.4.3 MySQL Community Server - GPL
Copyright (c) 2000, 2024, Oracle and/or its affiliates.
26 seconds ago Up 25
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> select version();+-----------+| version() |+-----------+| 8.4.3 |+-----------+1 row in set (0.01 sec)mysql> show databases;+--------------------+| Database |+--------------------+| information_schema || mysql || performance_schema || sys |+--------------------+4 rows in set (0.00 sec)mysql> exitByebash-5.1# exitexit
删除清理
[root@jyh ~]# docker stop mysqltest
mysqltest
[root@jyh ~]# docker rm mysqltest
mysqltest
[root@jyh ~]# docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
如果无法正常使用docker镜像仓库,可以使用以下指令进行导入导出
### 导出镜像
[root@jyh ~]# docker save -o MySQL843.tar mysql:8.4.3### 导入镜像
[root@jyh ~]# docker load -i MySQL843.tar7600fdef234b: Loading layer
[==================================================>] 116.5MB/116.5MBe17cefd60af0: Loading layer
[==================================================>] 11.26kB/11.26kB1fa6f54b3274: Loading layer
[==================================================>] 2.359MB/2.359MBaf5010f21ea7: Loading layer
[==================================================>] 17.18MB/17.18MBabee1c5192d7: Loading layer
[==================================================>] 6.656kB/6.656kB0576c12e071e: Loading layer
[==================================================>] 3.072kB/3.072kB
66e0995dbcea: Loading layer
[==================================================>] 140.6MB/140.6MB06bb0f112933: Loading layer
[==================================================>] 3.072kB/3.072kB793b5c3cdf77: Loading layer
[==================================================>] 335.2MB/335.2MB099ca8e33f5e: Loading layer
[==================================================>] 17.41kB/17.41kBLoaded image: mysql:8.4.3
源码部署
点击【MySQL Community Downloads】进入社区版下载界面,下拉框选择,点击【Download】下载
下载
[root@jyh ~]# wget https://cdn.mysql.com//Downloads/MySQL-8.4/mysql-8.4.3.tar.gz
--2025-01-07 00:11:01-- https://cdn.mysql.com//Downloads/MySQL-8.4/mysql-8.4.3.tar.gz
Resolving cdn.mysql.com (cdn.mysql.com)... 23.50.31.204, 2600:140e:6:3a8::1d68, 2600:140e:6:391::1d68
Connecting to cdn.mysql.com (cdn.mysql.com)|23.50.31.204|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 465097732 (444M) [application/x-tar-gz]
Saving to: ‘mysql-8.4.3.tar.gz’mysql-8.4.3.tar.gz 100%[==================>] 443.55M 3.54MB/s in 1m 46s2025-01-07 00:12:47 (4.20 MB/s) - ‘mysql-8.4.3.tar.gz’ saved [465097732/465097732]
清理之前的环境
[root@jyh ~]# dnf remove mysql-server -y
Updating Subscription Management repositories.
Unable to read consumer identityThis system is not registered with an entitlement server. You can use subscription-manager to register.No match for argument: mysql-server
No packages marked for removal.
Dependencies resolved.
Nothing to do.
Complete!
[root@jyh ~]# rm -rf /var/lib/mysql
[root@jyh ~]# rm -rf /var/log/mysqld.log
[root@jyh ~]# userdel -r mysql
userdel: user 'mysql' does not exist
在根目录中创建mysql目录
[root@jyh ~]# mkdir /mysql
[root@jyh ~]# mv mysql-8.4.3.tar.gz /mysql
[root@jyh ~]# cd /mysql
[root@jyh mysql]# ll
total 454200-rw-r--r--. 1 root root 465097732 Sep 17 17:12 mysql-8.4.3.tar.gz
解压源码包
[root@jyh mysql-8.4.3]# tar xf mysql-8.4.3.tar.gz
[root@jyh mysql]# ll
total 454204
drwxr-xr-x. 31 7161 31415 4096 Sep 17 19:09 mysql-8.4.3-rw-r--r--. 1 root root 465097732 Sep 17 17:12 mysql-8.4.3.tar.gz
[root@jyh mysql]# cd mysql-8.4.3/
[root@jyh mysql-8.4.3]# pwd
/mysql/mysql-8.4.3
创建用户,修改目录权限
[root@jyh mysql-8.4.3]# groupadd mysql
[root@jyh mysql-8.4.3]# useradd -r -g mysql -s /bin/false mysql
[root@jyh mysql-8.4.3]# chmod 777 /mysql/ -R
安装需要的软件
[root@jyh bld]# dnf install cmake openssl-devel ncurses-devel rpcgen gcc
toolset-12-gcc gcc-toolset-12-gcc-c++ gcc-toolset-12-binutils gcc-toolset-12
annobin-annocheck gcc-toolset-12-annobin-plugin-gcc
[root@jyh bld]# rpm -i
https://yum.oracle.com/repo/OracleLinux/OL9/codeready/builder/x86_64/getPackag
e/libtirpc-devel-1.3.3-9.el9.x86_64.rpm
warning: /var/tmp/rpm-tmp.KJQV1s: Header V3 RSA/SHA256 Signature, key ID
8d8b756f: NOKEY
配置并编译
[root@jyh bld]# cmake ..
[root@jyh bld]# make
[root@jyh bld]# make install
[root@jyh bld]# cd /usr/local/mysql
[root@jyh mysql]# mkdir mysql-files
[root@jyh mysql]# chown mysql:mysql mysql-files
[root@jyh mysql]# chmod 750 mysql-files
[root@jyh mysql]# bin/mysqld --initialize --user=mysql
2024-12-30T14:07:22.396459Z 0 [System] [MY-015017] [Server] MySQL Server
Initialization - start.
2024-12-30T14:07:22.397883Z 0 [System] [MY-013169] [Server]
/usr/local/mysql/bin/mysqld (mysqld 8.4.3) initializing of server in
progress as process 94087
2024-12-30T14:07:22.418620Z 1 [System] [MY-013576] [InnoDB] InnoDB
initialization has started.
2024-12-30T14:07:22.597559Z 1 [System] [MY-013577] [InnoDB] InnoDB
initialization has ended.
2024-12-30T14:07:23.220262Z 6 [Note] [MY-010454] [Server] A temporary
password is generated for root@localhost: H2!Yga+&rtiz
2024-12-30T14:07:24.762722Z 0 [System] [MY-015018] [Server] MySQL Server
Initialization - end.
[root@jyh mysql]# bin/mysqld_safe --user=mysql &
登录测试
[root@jyh mysql]# mysql -S /tmp/mysql.sock -uroot -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 8
Server version: 8.4.3
Copyright (c) 2000, 2024, 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> show databases;
ERROR 1820 (HY000): You must reset your password using ALTER USER statement
before executing this statement.
mysql> alter user 'root'@'localhost' identified by 'redhat';
Query OK, 0 rows affected (0.00 sec)
mysql> show databases;+--------------------+| Database |+--------------------+| information_schema || mysql || performance_schema || sys |+--------------------+
4 rows in set (0.01 sec)
删除清理
[root@jyh bld]# make clean
[root@jyh bld]# rm -rf /usr/local/mysql/
Windows平台
服务端安装
点击【MySQL Community(GPL) Downloads】进入社区版下载界面
点击【MySQL Community Server】进入下载页面
选择合适的版本和选项
下载完成,双击执行该可执行程序,打开欢迎页面,单击【Next】按钮进入下一步
进入到用户协议页面,选中复选框,单击【Next】按钮,进入下一步
进入安装类型选择页面,选择第一个【Typical】,选中后直接进行下一页
单击【Install】按钮进行安装
安装完成后,默认选中【Run MySQL Configurator】按钮,单击【Finish】按钮进行配置
进入配置页面,单击【Next】按钮进入下一步
进入选择数据目录页面,保持默认,单击【Next】按钮进入下一步
进入配置类型和网络配置页面,保持默认,单击【Next】按钮进入下一步
在账号和角色页面,我们输入 root 账号的密码并确认密码,默认不添加新账号,单击【Next】下一步
进入服务配置页面,保持默认,单击【Next】按钮进入下一步
进入服务权限页面,保持默认,单击【Next】按钮进入下一步
配置示例数据库是否要载入,选择载入,单击【Next】进行下一步
进入配置摘要页面,单击【Execute】按钮执行配置
配置执行完毕后,如下所示,单击【Next】进入下一步
显示配置完成的页面,单击【Finish】按钮完成配置
命令行测试
mysql> select version();+-----------+| version() |+-----------+| 8.4.3 |+-----------+1 row in set (0.00 sec)
mysql> show databases;+--------------------+| Database |+--------------------+| information_schema || mysql || performance_schema || sakila || sys || world |+--------------------+6 rows in set (0.02 sec)
图形客户端
以使用图形终端工具来进行连接使用
默认会话打开时,会提示有报错信息,按如下方法进行更改
保存成功后,再次打开 MySQL Workbench
环境变量配置
在配置环境变量之前,在命令行执行 mysql 客户端命令,则会出现以下提示
或者
找到如下页面,单击【高级系统设置】按钮
打开之后,如下图所示,单击【环境变量】按钮进行环境变量配置
打开如下页面,我们可以选择上面的用户变量配置,也可以选择下方的系统变量配置。我这里选择系统变量配置,在系统变量串口中选中【Path】变量,单击系统变量下方的【编辑】按钮
跳转到如下窗口,然后单击【新建】按钮
将如下路径添加到该变量
C:\Program Files\MySQL\MySQL Server 8.4\bin
单击【确定】关闭该窗口和之前的窗口,并且关闭命令行窗口再打开,再使用命令行
删除清理
在控制面板/程序和功能界面进行删除
或者设置/安装的应用界面中进行删除
软件卸载完成后,删除以下目录
C:\Program Files\MySQLC:\ProgramData\MySQLC:\Users\kittod\AppData\Roaming\MySQL
打开注册表编辑器工具
删除如下注册表项
HKEY_CURRENT_USER\Software\MySQLHKEY_CURRENT_USER\Software\MySQL ABHKEY_CURRENT_USER\Software\Oracle\MySQL WorkbenchHKEY_CURRENT_USER\Software\Oracle and/or its affiliates\MySQL Shell 8.4.3HKEY_LOCAL_MACHINE\SOFTWARE\MySQL AB